From 3b5bf5c91fe648f89c12dfeb4cda3fe36e7f19c5 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 26 Mar 2018 15:13:22 +0300 Subject: [PATCH] implied: improve handling of assignments in arguments This example code wasn't parsed correctly: if (IS_ERR(ptr = some_function())) { We should say basically use "ptr" as the implied arg instead of the assignment expression. Reported-by: Mauro Carvalho Chehab Signed-off-by: Dan Carpenter --- smatch_implied.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/smatch_implied.c b/smatch_implied.c index 8fbab237..35888163 100644 --- a/smatch_implied.c +++ b/smatch_implied.c @@ -914,6 +914,10 @@ void param_limit_implications(struct expression *expr, int param, char *key, cha if (!arg) return; + arg = strip_parens(arg); + while (arg->type == EXPR_ASSIGNMENT && arg->op == '=') + arg = strip_parens(arg->left); + name = get_variable_from_key(arg, key, &sym); if (!name || !sym) goto free; -- 2.11.4.GIT