From: Dan Carpenter Date: Fri, 15 Mar 2013 19:36:37 +0000 (+0300) Subject: extra: type bug handling for loops X-Git-Tag: 1.59~255 X-Git-Url: https://repo.or.cz/w/smatch.git/commitdiff_plain/a0dda6ebd813e4171c570ed6c8c703f862e4fa9a extra: type bug handling for loops This code was using the type of the limiter in the for condition as the type for the iterator. Signed-off-by: Dan Carpenter --- diff --git a/smatch_extra.c b/smatch_extra.c index bcff0a29..e4769010 100644 --- a/smatch_extra.c +++ b/smatch_extra.c @@ -226,7 +226,9 @@ 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_max(condition->right, &end)) + if (get_implied_max(condition->right, &end)) + end = sval_cast(get_type(iter_var), end); + else end = sval_type_max(get_type(iter_var)); if (get_sm_state_expr(SMATCH_EXTRA, condition->left) != sm)