From f8d0a2b3f69faf9c6fb2c2f0b35965d846550b1e Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 28 Feb 2023 08:19:21 +0300 Subject: [PATCH] hooks: save the container->owner This is a bit of a hack, and I don't currently have a use for it. I had a use planned but ended up doing it a different way. Still, I think I will end up using it so I'm going to commit this code. Signed-off-by: Dan Carpenter --- smatch.c | 3 +++ smatch_hooks.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/smatch.c b/smatch.c index 23ca3026..84ddce32 100644 --- a/smatch.c +++ b/smatch.c @@ -54,6 +54,7 @@ FILE *caller_info_fd; int sm_nr_errors; int sm_nr_checks; +int __cur_check_id; bool __silence_warnings_for_stmt; @@ -365,6 +366,7 @@ int main(int argc, char **argv) allocate_modification_hooks(); for (i = 1; i < ARRAY_SIZE(reg_funcs); i++) { + __cur_check_id = i; func = reg_funcs[i].func; /* The script IDs start at 1. 0 is used for internal stuff. */ @@ -373,6 +375,7 @@ int main(int argc, char **argv) strncmp(reg_funcs[i].name, "register_", 9) == 0) func(i); } + __cur_check_id = 0; smatch(filelist); free_string(data_dir); diff --git a/smatch_hooks.c b/smatch_hooks.c index 2a825d3a..3791bd99 100644 --- a/smatch_hooks.c +++ b/smatch_hooks.c @@ -95,10 +95,12 @@ DECLARE_PTR_LIST(scope_hook_list, struct scope_container); DECLARE_PTR_LIST(scope_hook_stack, struct scope_hook_list); static struct scope_hook_stack *scope_hooks; +extern int __cur_check_id; void add_hook(void *func, enum hook_type type) { struct hook_container *container = __alloc_hook_container(0); + container->owner = __cur_check_id; container->hook_type = type; container->fn = func; -- 2.11.4.GIT