From f0907fbac1f9ccdb5758bfa16ce67abeaa1220b3 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 7 Dec 2017 15:12:05 +0300 Subject: [PATCH] extra: pass expression pointer to mod/nomod hooks This doesn't always pass the expression pointer if there isn't one readily available. For example, at function declarations or when we're dealing with the DB then we might not have and expression pointer. Signed-off-by: Dan Carpenter --- check_rosenberg.c | 2 +- check_uninitialized.c | 2 +- check_user_data2.c | 2 +- smatch_extra.c | 10 +++++----- smatch_extra.h | 4 ++-- smatch_local_values.c | 2 +- smatch_param_filter.c | 2 +- smatch_param_limit.c | 2 +- smatch_param_set.c | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/check_rosenberg.c b/check_rosenberg.c index c62cd58e..2613c351 100644 --- a/check_rosenberg.c +++ b/check_rosenberg.c @@ -31,7 +31,7 @@ static int my_member_id; STATE(cleared); -static void extra_mod_hook(const char *name, struct symbol *sym, struct smatch_state *state) +static void extra_mod_hook(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state) { struct symbol *type; diff --git a/check_uninitialized.c b/check_uninitialized.c index 8742eee2..84cbe04a 100644 --- a/check_uninitialized.c +++ b/check_uninitialized.c @@ -77,7 +77,7 @@ static void match_declarations(struct symbol *sym) set_state(my_id, sym->ident->name, sym, &uninitialized); } -static void extra_mod_hook(const char *name, struct symbol *sym, struct smatch_state *state) +static void extra_mod_hook(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state) { if (!sym || !sym->ident) return; diff --git a/check_user_data2.c b/check_user_data2.c index 2d4a8de4..14aa5bef 100644 --- a/check_user_data2.c +++ b/check_user_data2.c @@ -93,7 +93,7 @@ static void pre_merge_hook(struct sm_state *sm) set_state(my_id, sm->name, sm->sym, alloc_estate_rl(clone_rl(rl))); } -static void extra_nomod_hook(const char *name, struct symbol *sym, struct smatch_state *state) +static void extra_nomod_hook(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state) { struct smatch_state *user; struct range_list *rl; diff --git a/smatch_extra.c b/smatch_extra.c index b06d344a..46b24257 100644 --- a/smatch_extra.c +++ b/smatch_extra.c @@ -60,7 +60,7 @@ static int in_warn_on_macro(void) return 0; } -typedef void (mod_hook)(const char *name, struct symbol *sym, struct smatch_state *state); +typedef void (mod_hook)(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state); DECLARE_PTR_LIST(void_fn_list, mod_hook *); static struct void_fn_list *extra_mod_hooks; static struct void_fn_list *extra_nomod_hooks; @@ -79,23 +79,23 @@ void add_extra_nomod_hook(mod_hook *fn) add_ptr_list(&extra_nomod_hooks, p); } -void call_extra_hooks(struct void_fn_list *hooks, const char *name, struct symbol *sym, struct smatch_state *state) +void call_extra_hooks(struct void_fn_list *hooks, const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state) { mod_hook **fn; FOR_EACH_PTR(hooks, fn) { - (*fn)(name, sym, state); + (*fn)(name, sym, expr, state); } END_FOR_EACH_PTR(fn); } void call_extra_mod_hooks(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state) { - call_extra_hooks(extra_mod_hooks, name, sym, state); + call_extra_hooks(extra_mod_hooks, name, sym, expr, state); } void call_extra_nomod_hooks(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state) { - call_extra_hooks(extra_nomod_hooks, name, sym, state); + call_extra_hooks(extra_nomod_hooks, name, sym, expr, state); } static bool in_param_set; diff --git a/smatch_extra.h b/smatch_extra.h index e45e08e5..cbac7b9b 100644 --- a/smatch_extra.h +++ b/smatch_extra.h @@ -160,8 +160,8 @@ void set_extra_expr_nomod(struct expression *expr, struct smatch_state *state); struct data_info *get_dinfo(struct smatch_state *state); -void add_extra_mod_hook(void (*fn)(const char *name, struct symbol *sym, struct smatch_state *state)); -void add_extra_nomod_hook(void (*fn)(const char *name, struct symbol *sym, struct smatch_state *state)); +void add_extra_mod_hook(void (*fn)(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state)); +void add_extra_nomod_hook(void (*fn)(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state)); int implied_not_equal(struct expression *expr, long long val); int implied_not_equal_name_sym(char *name, struct symbol *sym, long long val); int parent_is_null_var_sym(const char *name, struct symbol *sym); diff --git a/smatch_local_values.c b/smatch_local_values.c index b128ecaf..cffc2066 100644 --- a/smatch_local_values.c +++ b/smatch_local_values.c @@ -105,7 +105,7 @@ static struct smatch_state *unmatched_state(struct sm_state *sm) return alloc_estate_empty(); } -static void extra_mod_hook(const char *name, struct symbol *sym, struct smatch_state *state) +static void extra_mod_hook(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state) { struct smatch_state *old; struct smatch_state *new; diff --git a/smatch_param_filter.c b/smatch_param_filter.c index 2db881ae..01a9920f 100644 --- a/smatch_param_filter.c +++ b/smatch_param_filter.c @@ -91,7 +91,7 @@ static void pre_merge_hook(struct sm_state *sm) set_state(my_id, sm->name, sm->sym, alloc_estate_rl(clone_rl(rl))); } -static void extra_mod_hook(const char *name, struct symbol *sym, struct smatch_state *state) +static void extra_mod_hook(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state) { int param; diff --git a/smatch_param_limit.c b/smatch_param_limit.c index 0b426557..021da459 100644 --- a/smatch_param_limit.c +++ b/smatch_param_limit.c @@ -131,7 +131,7 @@ static void print_return_value_param(int return_id, char *return_ranges, struct } END_FOR_EACH_SM(tmp); } -static void extra_mod_hook(const char *name, struct symbol *sym, struct smatch_state *state) +static void extra_mod_hook(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state) { struct smatch_state *orig_vals; int param; diff --git a/smatch_param_set.c b/smatch_param_set.c index c7c3addc..21287a28 100644 --- a/smatch_param_set.c +++ b/smatch_param_set.c @@ -44,7 +44,7 @@ static struct smatch_state *unmatched_state(struct sm_state *sm) return alloc_estate_empty(); } -static void extra_mod_hook(const char *name, struct symbol *sym, struct smatch_state *state) +static void extra_mod_hook(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state) { if (get_param_num_from_sym(sym) < 0) return; -- 2.11.4.GIT