From 142082fc3737e915cd75bdbe2c31ca98519419f6 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 9 Dec 2014 13:17:54 +0300 Subject: [PATCH] param_limit: add comments and clarifications I added some comments explaining the point of this test. Also I re-arranged things a bit to hopefully make it a bit more clear. Signed-off-by: Dan Carpenter --- smatch_param_limit.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/smatch_param_limit.c b/smatch_param_limit.c index 29e23130..a389bc0c 100644 --- a/smatch_param_limit.c +++ b/smatch_param_limit.c @@ -16,6 +16,14 @@ */ /* + * This is almost the same as smatch_param_filter.c. The difference is that + * this only deals with values passed on the stack and param filter only deals + * with values changed so that the caller sees the new value. It other words + * the key for these should always be "$" and the key for param_filter should + * never be "$". Also smatch_param_set() should never use "$" as the key. + * Param set should work together with param_filter to determine the value that + * the caller sees at the end. + * * This is for functions like this: * * int foo(int a) @@ -51,7 +59,7 @@ static void save_start_states(struct statement *stmt) start_states = get_all_states_stree(SMATCH_EXTRA); } -static void match_end_func(void) +static void free_start_states(void) { free_stree(&start_states); } @@ -196,12 +204,14 @@ void register_param_limit(int id) my_id = id; add_hook(&save_start_states, AFTER_DEF_HOOK); + add_hook(&free_start_states, END_FUNC_HOOK); + add_extra_mod_hook(&extra_mod_hook); add_unmatched_state_hook(my_id, &unmatched_state); - add_split_return_callback(&print_return_value_param); - add_hook(&match_end_func, END_FUNC_HOOK); + add_hook(&match_save_states, INLINE_FN_START); add_hook(&match_restore_states, INLINE_FN_END); + add_split_return_callback(&print_return_value_param); } -- 2.11.4.GIT