From 9fbca0f7b8e24e5bc37de28cc541b7df131c8c26 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 10 Jan 2012 10:29:00 +0300 Subject: [PATCH] extra: cleanup: shuffle code around. This shouldn't change anything, it's just reworks things to hopefully make things more clear. Signed-off-by: Dan Carpenter --- smatch_extra.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/smatch_extra.c b/smatch_extra.c index b449221d..5e6ef05a 100644 --- a/smatch_extra.c +++ b/smatch_extra.c @@ -470,23 +470,21 @@ static void match_assign(struct expression *expr) goto free; } - if (expr->op == '=') { + known = get_implied_value(right, &value); + switch (expr->op) { + case '=': { struct range_list *rl = NULL; if (get_implied_range_list(right, &rl)) { set_extra_mod(name, sym, alloc_extra_state_range_list(rl)); - } else { - struct symbol *type = get_type(right); - - if (type && type_unsigned(type)) - min = 0; - set_extra_mod(name, sym, alloc_extra_state_range(min, max)); + goto free; } - goto free; - } - known = get_implied_value(right, &value); - if (expr->op == SPECIAL_ADD_ASSIGN) { + if (expr_unsigned(right)) + min = 0; + break; + } + case SPECIAL_ADD_ASSIGN: if (get_implied_min(left, &tmp)) { if (known) min = tmp + value; @@ -495,8 +493,8 @@ static void match_assign(struct expression *expr) } if (!inside_loop() && known && get_implied_max(left, &tmp)) max = tmp + value; - } - if (expr->op == SPECIAL_SUB_ASSIGN) { + break; + case SPECIAL_SUB_ASSIGN: if (get_implied_max(left, &tmp)) { if (known) max = tmp - value; @@ -505,6 +503,7 @@ static void match_assign(struct expression *expr) } if (!inside_loop() && known && get_implied_min(left, &tmp)) min = tmp - value; + break; } set_extra_mod(name, sym, alloc_extra_state_range(min, max)); free: -- 2.11.4.GIT