From mboxrd@z Thu Jan 1 00:00:00 1970 From: pierre-marc.fournier@polymtl.ca (Pierre-Marc Fournier) Date: Thu, 09 Sep 2010 02:23:04 -0400 Subject: [ltt-dev] [PATCH 1/2] Fix asprintf warning ignoring return value In-Reply-To: <20100903185224.GD3324@Krystal> References: <1283531871-10001-1-git-send-email-david.goulet@polymtl.ca> <20100903185224.GD3324@Krystal> Message-ID: <4C887D48.7060601@polymtl.ca> On 09/03/2010 02:52 PM, Mathieu Desnoyers wrote: > * David Goulet (david.goulet at polymtl.ca) wrote: >> Signed-off-by: David Goulet >> --- >> libust/tracectl.c | 63 ++++++++++++++++++++++++++++++++++++++++++-------- >> libustcmd/ustcmd.c | 41 +++++++++++++++++++++++++++----- >> libustcomm/ustcomm.c | 24 ++++++++++++++++--- >> libustd/libustd.c | 37 ++++++++++++++++++++++++---- >> tests/hello/hello.c | 6 +++- >> ustd/ustd.c | 12 ++++++++- >> 6 files changed, 152 insertions(+), 31 deletions(-) >> >> diff --git a/libust/tracectl.c b/libust/tracectl.c >> index ac551d5..1bb841f 100644 >> --- a/libust/tracectl.c >> +++ b/libust/tracectl.c >> @@ -156,7 +156,11 @@ static void inform_consumer_daemon(const char *trace_name) >> /* iterate on all cpus */ >> for(j=0; jchannels[i].n_cpus; j++) { >> char *buf; >> - asprintf(&buf, "%s_%d", trace->channels[i].channel_name, j); >> + if(asprintf(&buf, "%s_%d", trace->channels[i].channel_name, j) == -1) { > > please standardize on the kernel coding style: > > if () > for () > switch () > > but function() and macroname(). > > Also, please use a if (asprintf(...)< 0) test. I know the manpage > states that -1 is explicitely returned, but it's very typical for all > negative values to be more explicit error value variants. So let's make > these tests as similar as possible. > No. It's typical in the linux kernel, but not in unix userspace and not in ust internal apis. pmf