Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934980AbZLGKI2 (ORCPT ); Mon, 7 Dec 2009 05:08:28 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S934942AbZLGKIZ (ORCPT ); Mon, 7 Dec 2009 05:08:25 -0500 Received: from mx.sz.bfs.de ([194.94.69.70]:40304 "EHLO mx.sz.bfs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934938AbZLGKIY (ORCPT ); Mon, 7 Dec 2009 05:08:24 -0500 Message-ID: <4B1CD40F.4010407@bfs.de> Date: Mon, 07 Dec 2009 11:08:15 +0100 From: walter harms Reply-To: wharms@bfs.de User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Julia Lawall Cc: Peter Zijlstra , Paul Mackerras , Ingo Molnar , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH 4/5] tools/perf/util: correct size computation References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1271 Lines: 49 Julia Lawall schrieb: > From: Julia Lawall > > 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/) > > // > @expression@ > expression *x; > @@ > > x = > <+... > -sizeof(x) > +sizeof(*x) > ...+>// > > Signed-off-by: Julia Lawall > > --- > 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/