From: Dan Carpenter Date: Mon, 19 Nov 2012 20:02:40 +0000 (+0300) Subject: sval: math: fix get_value() for !foo X-Git-Tag: 1.57~181 X-Git-Url: https://repo.or.cz/w/smatch.git/commitdiff_plain/8fa8b3bec8abbe3ea202f9bc0615fafe5002d241 sval: math: fix get_value() for !foo handle_negate() was only checking the implied values, not the known values. Signed-off-by: Dan Carpenter --- diff --git a/smatch_math.c b/smatch_math.c index b88980b5..355d294c 100644 --- a/smatch_math.c +++ b/smatch_math.c @@ -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;