From: Dan Carpenter Date: Wed, 28 May 2014 10:45:58 +0000 (+0300) Subject: extra: more limits on which variables are equivalent X-Git-Tag: 1.60~241 X-Git-Url: https://repo.or.cz/w/smatch.git/commitdiff_plain/72dc848f8a83d2af7d2c09e7c20f35e35e2dcaf8 extra: more limits on which variables are equivalent If the assignment is: foo = &bar; Then we don't record that as equivalent. Unfortunately, I can't remember why this is. Probably it is because we don't record the state of &bar in smatch_extra so they become out of sync. If the assignment is: foo = foo->bar; Then the problem is that after the assignment then the right side of the assignment has changed so foo != foo->bar at the end. Signed-off-by: Dan Carpenter --- diff --git a/smatch_extra.c b/smatch_extra.c index f14c5be3..08dcb5da 100644 --- a/smatch_extra.c +++ b/smatch_extra.c @@ -514,8 +514,11 @@ static void match_vanilla_assign(struct expression *left, struct expression *rig right_type = get_type(right); right_name = expr_to_var_sym(right, &right_sym); - if (right_name && right_sym && - types_equiv_or_pointer(left_type, right_type)) { + + if (!(right->type == EXPR_PREOP && right->op == '&') && + right_name && right_sym && + types_equiv_or_pointer(left_type, right_type) && + !has_symbol(right, sym)) { set_equiv(left, right); goto free; }