From 90e8c737b014106c371894e8d1314a913eb7d135 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 13 Jun 2013 11:59:52 +0300 Subject: [PATCH] db: shift some code around in storing return ranges I've split the part the gets the return range string into a separate function. Signed-off-by: Dan Carpenter --- smatch_db.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/smatch_db.c b/smatch_db.c index 6785ac7b..faa47cd2 100644 --- a/smatch_db.c +++ b/smatch_db.c @@ -799,33 +799,42 @@ static int call_return_state_hooks_split_possible(struct expression *expr) return ret; } +static char *get_return_ranges_str(struct expression *expr) +{ + struct range_list *rl; + char *return_ranges; + + if (!expr) + return alloc_sname(""); + if (get_implied_rl(expr, &rl) && !is_whole_rl(rl)) { + rl = cast_rl(cur_func_return_type(), rl); + return show_rl(rl); + } + return_ranges = range_comparison_to_param(expr); + if (return_ranges) + return return_ranges; + rl = cast_rl(cur_func_return_type(), alloc_whole_rl(get_type(expr))); + return_ranges = show_rl(rl); + return return_ranges; +} + static void call_return_state_hooks(struct expression *expr) { struct returned_state_callback *cb; - struct range_list *rl; char *return_ranges; int nr_states; expr = strip_expr(expr); - if (!expr) { - return_ranges = alloc_sname(""); - } else if (is_condition(expr)) { + if (is_condition(expr)) { call_return_state_hooks_compare(expr); return; } else if (call_return_state_hooks_split_possible(expr)) { return; - } else if (get_implied_rl(expr, &rl) && !is_whole_rl(rl)) { - rl = cast_rl(cur_func_return_type(), rl); - return_ranges = show_rl(rl); - } else { - return_ranges = range_comparison_to_param(expr); - if (!return_ranges) { - rl = cast_rl(cur_func_return_type(), alloc_whole_rl(get_type(expr))); - return_ranges = show_rl(rl); - } } + return_ranges = get_return_ranges_str(expr); + return_id++; nr_states = ptr_list_size((struct ptr_list *)__get_cur_slist()); if (nr_states >= 10000) { -- 2.11.4.GIT