From: Dan Carpenter Date: Sat, 6 Jul 2013 08:26:39 +0000 (+0300) Subject: extra: handle binop comparisons better X-Git-Tag: 1.59~10 X-Git-Url: https://repo.or.cz/w/smatch.git/commitdiff_plain/c5ed36386e0f6ee08bf8e52638ac68c9becfdd2b extra: handle binop comparisons better This probably doesn't make such a big difference, but it does silence a kernel false positive. If you have an binop with implied values then move them to the same side: size = sizeof(struct foo) if (x - 2 > size) { The size of "x" at the end should be known. Signed-off-by: Dan Carpenter --- diff --git a/smatch_extra.c b/smatch_extra.c index f7eabf67..974d1531 100644 --- a/smatch_extra.c +++ b/smatch_extra.c @@ -1016,7 +1016,7 @@ static void move_known_values(struct expression **left_p, struct expression **ri struct expression *right = *right_p; sval_t sval; - if (get_value(left, &sval)) { + if (get_implied_value(left, &sval)) { if (!is_simple_math(right)) return; if (right->op == '+' && get_value(right->left, &sval)) { @@ -1031,7 +1031,7 @@ static void move_known_values(struct expression **left_p, struct expression **ri } return; } - if (get_value(right, &sval)) { + if (get_implied_value(right, &sval)) { if (!is_simple_math(left)) return; if (left->op == '+' && get_value(left->left, &sval)) {