From 9236ba9ab11124f44213c9ec92e9e7d1f73087e2 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 7 Nov 2012 15:51:22 +0300 Subject: [PATCH] sval: fix a bug in handling for loops that count downwards It should be counting down to min, but there was a bug so max was used instead. Also I've removed a whole_range reference. Signed-off-by: Dan Carpenter --- smatch_extra.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smatch_extra.c b/smatch_extra.c index 8c3a3860..6788322a 100644 --- a/smatch_extra.c +++ b/smatch_extra.c @@ -262,14 +262,14 @@ static struct sm_state *handle_canonical_for_dec(struct expression *iter_expr, if (!estate_get_single_value_sval(sm->state, &start)) return NULL; if (!get_implied_value_sval(condition->right, &end)) - end = ll_to_sval(whole_range.max); + end = sval_type_min(get_type(iter_var)); if (get_sm_state_expr(SMATCH_EXTRA, condition->left) != sm) return NULL; switch (condition->op) { case SPECIAL_NOTEQUAL: case '>': - if (!sval_is_max(end)) + if (!sval_is_min(end) && !sval_is_max(end)) end.value++; break; case SPECIAL_GTE: -- 2.11.4.GIT