[ltt-dev] [PATCH 1/2] Fix asprintf warning ignoring return value

Pierre-Marc Fournier pierre-marc.fournier at polymtl.ca
Thu Sep 9 02:23:04 EDT 2010


On 09/03/2010 02:52 PM, Mathieu Desnoyers wrote:
> * David Goulet (david.goulet at polymtl.ca) wrote:
>> Signed-off-by: David Goulet<david.goulet at polymtl.ca>
>> ---
>>   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; j<trace->channels[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




More information about the lttng-dev mailing list