From c5ed36386e0f6ee08bf8e52638ac68c9becfdd2b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sat, 6 Jul 2013 11:26:39 +0300 Subject: [PATCH] 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 --- smatch_extra.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)) { -- 2.11.4.GIT