From 8f20339fb4c586cc4c55f984d01babee071bfddc Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 23 Nov 2012 14:51:50 +0300 Subject: [PATCH] math: overflows in hard max are undefined If the calculation overflows then by definition, it's sort of not a hard max. Signed-off-by: Dan Carpenter --- smatch_math.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/smatch_math.c b/smatch_math.c index c022db8e..6e57a3da 100644 --- a/smatch_math.c +++ b/smatch_math.c @@ -284,10 +284,15 @@ static sval_t handle_binop(struct expression *expr, int *undefined, int implied) switch (implied) { case IMPLIED_MAX: case FUZZY_MAX: - case HARD_MAX: case ABSOLUTE_MAX: if (sval_binop_overflows(left, expr->op, right)) return sval_type_max(get_type(expr)); + break; + case HARD_MAX: + if (sval_binop_overflows(left, expr->op, right)) { + *undefined = 1; + return bogus; + } } switch (expr->op) { -- 2.11.4.GIT