From: Dan Carpenter Date: Fri, 15 Mar 2013 19:34:23 +0000 (+0300) Subject: math: fix a couple type bugs X-Git-Tag: 1.59~256 X-Git-Url: https://repo.or.cz/w/smatch.git/commitdiff_plain/bd25026ed4d4ad427eabbb4be5605e9f2bcad9f0 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 --- 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);