perf tools: Correct size given to memset

Author: Julia Lawall <julia@diku.dk>

Memset should be given the size of the structure, not the size
of the pointer.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// 
@@
type T;
T *x;
expression E;
@@

memset(x, E, sizeof(
+ *
 x))
// 

Signed-off-by: Julia Lawall 
Cc: Peter Zijlstra 
Cc: Paul Mackerras 
LKML-Reference: 
Signed-off-by: Ingo Molnar 
---
 tools/perf/util/probe-event.c       | 2 +-
 tools/perf/util/trace-event-parse.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
 
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 9480d99..d14a458 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -376,7 +376,7 @@ static void clear_probe_point(struct probe_point *pp)
 		free(pp->args);
 	for (i = 0; i < pp->found; i++)
 		free(pp->probes[i]);
-	memset(pp, 0, sizeof(pp));
+	memset(pp, 0, sizeof(*pp));
 }
 
 /* Show an event */
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 6ffe9d6..c5c32be 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -1477,7 +1477,7 @@ process_fields(struct event *event, struct print_flag_sym **list, char **tok)
 			goto out_free;
 
 		field = malloc_or_die(sizeof(*field));
-		memset(field, 0, sizeof(field));
+		memset(field, 0, sizeof(*field));
 
 		value = arg_eval(arg);
 		field->value = strdup(value);
BtrLinux
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.