From a0dda6ebd813e4171c570ed6c8c703f862e4fa9a Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 15 Mar 2013 22:36:37 +0300 Subject: [PATCH] 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 --- smatch_extra.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) -- 2.11.4.GIT