Powered by Linux
[PATCH 1/2] smatch_allocations: Record the function that allocates memory — Semantic Matching Tool

[PATCH 1/2] smatch_allocations: Record the function that allocates memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
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




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux