perf tools: Correct size given to memset
authorJulia Lawall <julia@diku.dk>
Wed, 9 Dec 2009 19:26:18 +0000 (20:26 +0100)
committerIngo Molnar <mingo@elte.hu>
Thu, 10 Dec 2009 07:30:26 +0000 (08:30 +0100)
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
tools/perf/util/trace-event-parse.c

index 9480d9941cc0453a47816e05e1b3bf7847db613c..d14a4585bcafb53fd8a9f664ff50e32e8ca9f95b 100644 (file)
@@ -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 */
index 6ffe9d63d85d88a4a7297ac2695b6f66a3d62904..c5c32be040bfe85767a155bb951db828aff4e49a 100644 (file)
@@ -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);