extra: get max correctly
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 23 Nov 2012 11:21:52 +0000 (23 14:21 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Fri, 23 Nov 2012 11:21:52 +0000 (23 14:21 +0300)
The original code only took known values or the type max but the intent
was to use the implied max or the type max.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch_extra.c

index ba8da2c..50c3c11 100644 (file)
@@ -220,7 +220,7 @@ static struct sm_state *handle_canonical_for_inc(struct expression *iter_expr,
                return NULL;
        if (!estate_get_single_value(sm->state, &start))
                return NULL;
-       if (!get_implied_value(condition->right, &end))
+       if (!get_implied_max(condition->right, &end))
                end = sval_type_max(get_type(iter_var));
 
        if (get_sm_state_expr(SMATCH_EXTRA, condition->left) != sm)
@@ -260,7 +260,7 @@ static struct sm_state *handle_canonical_for_dec(struct expression *iter_expr,
                return NULL;
        if (!estate_get_single_value(sm->state, &start))
                return NULL;
-       if (!get_implied_value(condition->right, &end))
+       if (!get_implied_min(condition->right, &end))
                end = sval_type_min(get_type(iter_var));
        if (get_sm_state_expr(SMATCH_EXTRA, condition->left) != sm)
                return NULL;