From 36b582e34077158fa5678a568fc89d55ffbb9593 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 27 Feb 2014 12:49:54 +0300 Subject: [PATCH] extra: fix unknown += assignments The if we have: u64 x; u32 y; x += y; Then we don't know the value of x, it could be 0-u64max. In the original code we said that it could go up to u32max. The first part of this function changes it to take the range from "x" instead of "y". The next part of this patch says that we should be calculating the absolute max instead of saying it was unknown anyway. This mostly makes the first change irrelevant. Signed-off-by: Dan Carpenter --- smatch_extra.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/smatch_extra.c b/smatch_extra.c index 6be3a04f..af5772a9 100644 --- a/smatch_extra.c +++ b/smatch_extra.c @@ -601,8 +601,8 @@ static void match_assign(struct expression *expr) left_type = get_type(left); right_type = get_type(right); - res_min = sval_type_min(right_type); - res_max = sval_type_max(right_type); + res_min = sval_type_min(left_type); + res_max = sval_type_max(left_type); switch (expr->op) { case SPECIAL_ADD_ASSIGN: @@ -651,7 +651,7 @@ static void match_assign(struct expression *expr) binop_expr = binop_expression(expr->left, op_remove_assign(expr->op), expr->right); - if (get_implied_rl(binop_expr, &rl)) { + if (get_absolute_rl(binop_expr, &rl)) { rl = cast_rl(left_type, rl); set_extra_mod(name, sym, alloc_estate_rl(rl)); goto free; -- 2.11.4.GIT