lkml.org 
[lkml]   [2009]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/5] tools/perf/util: correct size computation


Julia Lawall schrieb:
> From: Julia Lawall <julia@diku.dk>
>
> The size argument to zalloc should be the size of desired structure,
> not the pointer to it.
>
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @expression@
> expression *x;
> @@
>
> x =
> <+...
> -sizeof(x)
> +sizeof(*x)
> ...+>// </smpl>
>
> Signed-off-by: Julia Lawall <julia@diku.dk>
>
> ---
> tools/perf/util/parse-events.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff -u -p a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -197,7 +197,7 @@ struct tracepoint_path *tracepoint_id_to
> if (id == config) {
> closedir(evt_dir);
> closedir(sys_dir);
> - path = zalloc(sizeof(path));
> + path = zalloc(sizeof(*path));
> path->system = malloc(MAX_EVENT_LENGTH);
> if (!path->system) {
> free(path);

and zalloc() can not fail ?
re,
wh


\
 
 \ /
  Last update: 2009-12-07 11:11    [W:0.029 / U:2.036 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site