Smatch (Semantic Matching Tool) development
 help / color / mirror / Atom feed
* [PATCH 1/2] smatch_allocations: Record the function that allocates memory
@ 2022-08-15 16:20 Christophe JAILLET
  2022-08-15 16:21 ` [PATCH 2/2] check_freeing_devm: Take advantage of the new add_allocation hook Christophe JAILLET
  2022-08-16  8:10 ` [PATCH 1/2] smatch_allocations: Record the function that allocates memory Dan Carpenter
  0 siblings, 2 replies; 4+ messages in thread
From: Christophe JAILLET @ 2022-08-15 16:20 UTC (permalink / raw)
  To: smatch; +Cc: Christophe JAILLET

Keep track of the name of the function that did the memory allocation.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Not sure if it is the best way to save this information. Maybe it can
already be retrieved another way (from expr directly?)

An example of why it could be useful is in patch 2/2.
---
 smatch.h             | 1 +
 smatch_allocations.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/smatch.h b/smatch.h
index 36ae3497d8de..00a7563185e6 100644
--- a/smatch.h
+++ b/smatch.h
@@ -174,6 +174,7 @@ void call_name_sym_fns(struct name_sym_fn_list *list, struct expression *expr, c
 void call_string_hooks(struct string_hook_list *list, struct expression *expr, const char *str);
 
 struct allocation_info {
+	const char *fn_name;
 	const char *size_str;
 	struct expression *total_size;
 	struct expression *nr_elems;
diff --git a/smatch_allocations.c b/smatch_allocations.c
index 599f195a4c31..08957f3e0902 100644
--- a/smatch_allocations.c
+++ b/smatch_allocations.c
@@ -98,6 +98,7 @@ static void match_alloc(struct expression *expr, const char *name, struct symbol
 	struct allocation_info data = { };
 	alloc_hook *fn;
 
+	data.fn_name = info->name;
 	data.size_str = info->size;
 	data.zeroed = info->zeroed;
 
-- 
2.34.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-16 10:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-15 16:20 [PATCH 1/2] smatch_allocations: Record the function that allocates memory Christophe JAILLET
2022-08-15 16:21 ` [PATCH 2/2] check_freeing_devm: Take advantage of the new add_allocation hook Christophe JAILLET
2022-08-16  8:12   ` Dan Carpenter
2022-08-16  8:10 ` [PATCH 1/2] smatch_allocations: Record the function that allocates memory Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox