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

From: Arnaldo Carvalho de Melo
Date: Mon Dec 16 2013 - 07:41:10 EST


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.

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/