From: Mike Frysinger Date: Fri, 6 Jan 2012 01:51:37 -0500 Subject: [U-Boot] [PATCH] lib/string: added strndup In-Reply-To: <20120105232506.6C840B6F26@gemini.denx.de> References: <1324577816-26198-1-git-send-email-marathon96@gmail.com> <201201051821.35774.vapier@gentoo.org> <20120105232506.6C840B6F26@gemini.denx.de> Message-ID: <201201060151.38282.vapier@gentoo.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Thursday 05 January 2012 18:25:06 Wolfgang Denk wrote: > Mike Frysinger 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. sure, np -mike -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part. URL: