sval: math: fix get_value() for !foo
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 19 Nov 2012 20:02:40 +0000 (19 23:02 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Mon, 19 Nov 2012 20:02:40 +0000 (19 23:02 +0300)
handle_negate() was only checking the implied values, not the known
values.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch_math.c

index b88980b..355d294 100644 (file)
@@ -101,6 +101,17 @@ static sval_t handle_negate(struct expression *expr, int *undefined, int implied
        sval_t ret;
 
        ret = sval_blank(expr->unop);
+
+       if (known_condition_true(expr->unop)) {
+               ret.value = 0;
+               return ret;
+       }
+
+       if (implied == NOTIMPLIED) {
+               *undefined = 1;
+               return bogus;
+       }
+
        if (implied_condition_true(expr->unop)) {
                ret.value = 0;
                return ret;