From 12c15b0c7e17434b872917c4cc0640ad399f2903 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 15 Mar 2013 22:58:53 +0300 Subject: [PATCH] math: Use function call information It already used to use function call information if you called get_implied_rl(). But it didn't if you did get_implied_max(). This fixes that. Signed-off-by: Dan Carpenter --- smatch_math.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/smatch_math.c b/smatch_math.c index 9b596ccc..33954777 100644 --- a/smatch_math.c +++ b/smatch_math.c @@ -704,6 +704,36 @@ static sval_t handle_sizeof(struct expression *expr) return ret; } +static sval_t handle_call(struct expression *expr, int *undefined, int implied) +{ + struct range_list *rl; + + if (!get_implied_rl(expr, &rl)) { + *undefined = 1; + return bogus; + } + + switch (implied) { + case IMPLIED: + if (sval_cmp(rl_min(rl), rl_max(rl)) == 0) + return rl_min(rl); + *undefined = 1; + return bogus; + case IMPLIED_MIN: + case ABSOLUTE_MIN: + return rl_min(rl); + + case IMPLIED_MAX: + case HARD_MAX: + case ABSOLUTE_MAX: + return rl_max(rl); + default: + *undefined = 1; + return bogus; + } + +} + static sval_t _get_value(struct expression *expr, int *undefined, int implied) { sval_t ret; @@ -756,6 +786,9 @@ static sval_t _get_value(struct expression *expr, int *undefined, int implied) case EXPR_CONDITIONAL: ret = handle_conditional(expr, undefined, implied); break; + case EXPR_CALL: + ret = handle_call(expr, undefined, implied); + break; default: ret = _get_implied_value(expr, undefined, implied); } -- 2.11.4.GIT