Skip to content

Commit

Permalink
perf tools: Correct size given to memset
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Julia Lawall authored and Ingo Molnar committed Dec 10, 2009
1 parent 21140f4 commit 5660ce3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/perf/util/probe-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/trace-event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5660ce3

Please sign in to comment.