From d082eb8328bdf1fc2944c8e2d4a9c70100abe494 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 2 Aug 2022 15:21:39 +0300 Subject: [PATCH] allocation_funcs: handle inline functions better This code did not preserve the "returns_old/new_stuff" correctly across inline calls correctly. Just use the add_function_data() hook to do it. Signed-off-by: Dan Carpenter --- check_allocation_funcs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/check_allocation_funcs.c b/check_allocation_funcs.c index 4972907f..03952113 100644 --- a/check_allocation_funcs.c +++ b/check_allocation_funcs.c @@ -79,8 +79,9 @@ free: free_string(left_name); } -static int returns_new_stuff = 0; -static int returns_old_stuff = 0; +static unsigned long returns_new_stuff; +static unsigned long returns_old_stuff; + static void match_return(struct expression *ret_value) { char *name; @@ -110,8 +111,6 @@ static void match_end_func(struct symbol *sym) if (returns_new_stuff && !returns_old_stuff) sm_info("allocation func"); free_trackers_and_list(&allocated); - returns_new_stuff = 0; - returns_old_stuff = 0; } void check_allocation_funcs(int id) @@ -122,6 +121,9 @@ void check_allocation_funcs(int id) return; my_id = id; + + add_function_data(&returns_old_stuff); + add_function_data(&returns_new_stuff); add_hook(&match_return, RETURN_HOOK); add_hook(&match_end_func, AFTER_FUNC_HOOK); for (i = 0; allocation_funcs[i]; i++) { -- 2.11.4.GIT