From 4c14045e58726c35554504f1bbf8740343be4625 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 9 Jun 2015 17:45:51 +0300 Subject: [PATCH] math: handle __smatch_implied(&foo->bar) a little better If you have: __smatch_implied(&foo->bar); and ->bar is not the first struct member then you know the address is non-zero. Add this to smatch_math.c. Signed-off-by: Dan Carpenter --- smatch_math.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/smatch_math.c b/smatch_math.c index 1ae4e901..37cca611 100644 --- a/smatch_math.c +++ b/smatch_math.c @@ -61,10 +61,14 @@ static struct range_list *handle_expression_statement_rl(struct expression *expr return last_stmt_rl(get_expression_statement(expr), implied); } -static struct range_list *handle_ampersand_rl(int implied) +static struct range_list *handle_ampersand_rl(struct expression *expr, int implied) { + struct range_list *rl; + if (implied == RL_EXACT || implied == RL_HARD) return NULL; + if (get_address_rl(expr, &rl)) + return rl; return alloc_rl(valid_ptr_min_sval, valid_ptr_max_sval); } @@ -114,7 +118,7 @@ static struct range_list *handle_preop_rl(struct expression *expr, int implied) { switch (expr->op) { case '&': - return handle_ampersand_rl(implied); + return handle_ampersand_rl(expr, implied); case '!': return handle_negate_rl(expr, implied); case '~': -- 2.11.4.GIT