From: Wolfgang Denk Date: Fri, 06 Jan 2012 00:25:06 +0100 Subject: [U-Boot] [PATCH] lib/string: added strndup In-Reply-To: <201201051821.35774.vapier@gentoo.org> References: <1324577816-26198-1-git-send-email-marathon96@gmail.com> <201201051821.35774.vapier@gentoo.org> Message-ID: <20120105232506.6C840B6F26@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Mike Frysinger, In message <201201051821.35774.vapier@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.