From 891d09df420ec728178b37cae673e0222ccb35df Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 22 Jun 2018 14:15:32 +0300 Subject: [PATCH] modification_hooks: don't allow multiple modification hooks I had a bug where I set multiple modification hooks and it took a while to debug. Don't allow that. Signed-off-by: Dan Carpenter --- smatch_modification_hooks.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/smatch_modification_hooks.c b/smatch_modification_hooks.c index 548d5e2e..6bd0eb96 100644 --- a/smatch_modification_hooks.c +++ b/smatch_modification_hooks.c @@ -68,11 +68,19 @@ static struct smatch_state *alloc_my_state(struct expression *expr, struct smatc void add_modification_hook(int owner, modification_hook *call_back) { + if (hooks[owner]) { + printf("multiple modification hooks for %s\n", check_name(owner)); + exit(1); + } hooks[owner] = call_back; } void add_modification_hook_late(int owner, modification_hook *call_back) { + if (hooks_late[owner]) { + printf("multiple late modification hooks for %s\n", check_name(owner)); + exit(1); + } hooks_late[owner] = call_back; } -- 2.11.4.GIT