[U-Boot] [PATCH] lib/string: added strndup

Wolfgang Denk wd at denx.de
Fri Jan 6 00:25:06 CET 2012


Dear Mike Frysinger,

In message <201201051821.35774.vapier at gentoo.org> you wrote:
>
> > +	if ((s == NULL) ||
> > +		((new = malloc (len + 1)) == NULL) ) {
> > +		return NULL;
> > +	}
>
> please split this up such as:

I'm OK with the splitting, but...

> 	if (s == NULL)
> 		return s;
>
> 	new = malloc(len + 1);
> 	if (new == NULL)
> 		return new;

... in both cases, a "return NULL" is much easier to parse for the
human and identical for the compiler, so that should be used.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Good morning. This is the telephone company. Due  to  repairs,  we're
giving  you  advance notice that your service will be cut off indefi-
nitely at ten o'clock. That's two minutes from now.


More information about the U-Boot mailing list