lkml.org 
[lkml]   [2013]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 13/14] tools lib traceevent: Get rid of die() in some string conversion funcitons
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


\
 
 \ /
  Last update: 2013-12-16 14:21    [W:0.111 / U:0.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site