Re: [PATCH 13/14] tools lib traceevent: Get rid of die() in some string conversion funcitons

From: Namhyung Kim
Date: Mon Dec 16 2013 - 19:02:43 EST


Hi Arnaldo,

On Mon, 16 Dec 2013 09:40:51 -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Dec 16, 2013 at 01:49:11PM +0900, Namhyung Kim escreveu:
>> On Fri, 13 Dec 2013 11:52:04 -0300, Arnaldo Carvalho de Melo wrote:
>> > All the rest is ok, so its just the malloc + strcpy that remains to be
>> > converted, do you want me to do it?
>
>> Hmm.. did you mean like this?
>
>> str = NULL;
>> if (val)
>> asprintf(&str, "TRUE");
>> else
>> asprintf(&str, "FALSE");
>> return str;
>
> More compact:
>
> if (asprintf(&str, "%s", val ? "TRUE" : "FALSE") < 0)
> // error handling path
>
> At that point str already is set to NULL.

Okay, this is a new one: