mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 12/12] tools/perf: Correct size given to memset
@ 2009-12-09 19:26 Julia Lawall
  2009-12-10  7:50 ` [tip:perf/urgent] perf tools: " tip-bot for Julia Lawall
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2009-12-09 19:26 UTC (permalink / raw)
  To: Peter Zijlstra, Paul Mackerras, Ingo Molnar, linux-kernel,
	kernel-janitors

From: 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/)

// <smpl>
@@
type T;
T *x;
expression E;
@@

memset(x, E, sizeof(
+ *
 x))
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 tools/perf/util/probe-event.c       |    2 +-
 tools/perf/util/trace-event-parse.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff -u -p a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -376,7 +376,7 @@ static void clear_probe_point(struct pro
 		free(pp->args);
 	for (i = 0; i < pp->found; i++)
 		free(pp->probes[i]);
-	memset(pp, 0, sizeof(pp));
+	memset(pp, 0, sizeof(*pp));
 }
 
 /* List up current perf-probe events */
diff -u -p a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
--- 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, stru
 			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);

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

* [tip:perf/urgent] perf tools: Correct size given to memset
  2009-12-09 19:26 [PATCH 12/12] tools/perf: Correct size given to memset Julia Lawall
@ 2009-12-10  7:50 ` tip-bot for Julia Lawall
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Julia Lawall @ 2009-12-10  7:50 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, paulus, julia, hpa, mingo, a.p.zijlstra, tglx, mingo

Commit-ID:  5660ce34241ab204bf78fbcaa5e09318c2748d37
Gitweb:     http://git.kernel.org/tip/5660ce34241ab204bf78fbcaa5e09318c2748d37
Author:     Julia Lawall <julia@diku.dk>
AuthorDate: Wed, 9 Dec 2009 20:26:18 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 10 Dec 2009 08:30:26 +0100

perf tools: Correct size given to memset

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/)

// <smpl>
@@
type T;
T *x;
expression E;
@@

memset(x, E, sizeof(
+ *
 x))
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <Pine.LNX.4.64.0912092026000.1870@ask.diku.dk>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 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);

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

end of thread, other threads:[~2009-12-10  7:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-09 19:26 [PATCH 12/12] tools/perf: Correct size given to memset Julia Lawall
2009-12-10  7:50 ` [tip:perf/urgent] perf tools: " tip-bot for Julia Lawall

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

Powered by JetHome