From bd25026ed4d4ad427eabbb4be5605e9f2bcad9f0 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 15 Mar 2013 22:34:23 +0300 Subject: [PATCH] math: fix a couple type bugs In do_comparison() there were situations where the results where it said that the condition was always true and always false because the type was incorrect. In handle_mod() the min and max should be the same type which is the type for the whole expression. Signed-off-by: Dan Carpenter --- smatch_math.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/smatch_math.c b/smatch_math.c index 820083d2..9b596ccc 100644 --- a/smatch_math.c +++ b/smatch_math.c @@ -269,7 +269,7 @@ static sval_t handle_mod(struct expression *expr, int *undefined, int implied) case FUZZY_MIN: case ABSOLUTE_MIN: *undefined = 0; - return sval_type_val(get_type(expr->left), 0); + return sval_type_val(get_type(expr), 0); case IMPLIED_MAX: case FUZZY_MAX: case ABSOLUTE_MAX: @@ -375,9 +375,14 @@ static int do_comparison(struct expression *expr) struct range_list *left_ranges = NULL; struct range_list *right_ranges = NULL; int poss_true, poss_false; + struct symbol *type; + + type = get_type(expr); get_implied_rl(expr->left, &left_ranges); get_implied_rl(expr->right, &right_ranges); + left_ranges = cast_rl(type, left_ranges); + right_ranges = cast_rl(type, right_ranges); poss_true = possibly_true_rl(left_ranges, expr->op, right_ranges); poss_false = possibly_false_rl(left_ranges, expr->op, right_ranges); -- 2.11.4.GIT