extra: handle binop comparisons better
authorDan Carpenter <dan.carpenter@oracle.com>
Sat, 6 Jul 2013 08:26:39 +0000 (6 11:26 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Sat, 6 Jul 2013 08:26:39 +0000 (6 11:26 +0300)
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 <dan.carpenter@oracle.com>
smatch_extra.c

index f7eabf6..974d153 100644 (file)
@@ -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)) {