From: Mike Frysinger Date: Mon, 12 Sep 2011 16:24:03 -0400 Subject: [U-Boot] [PATCH] net: turn name len check into an assert In-Reply-To: <201109121906.13752.marek.vasut@gmail.com> References: <1315802993-12798-1-git-send-email-vapier@gentoo.org> <201109121229.11257.vapier@gentoo.org> <201109121906.13752.marek.vasut@gmail.com> Message-ID: <201109121624.03754.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 Monday, September 12, 2011 13:06:13 Marek Vasut wrote: > On Monday, September 12, 2011 06:29:10 PM Mike Frysinger wrote: > > On Monday, September 12, 2011 01:08:50 Marek Vasut wrote: > > > On Monday, September 12, 2011 06:49:53 AM Mike Frysinger wrote: > > > > --- a/net/eth.c > > > > +++ b/net/eth.c > > > > > > > > - size_t len = strlen(dev->name); > > > > - if (len >= NAMESIZE) { > > > > - printf("Network driver name is too long (%zu >= %zu): %s\n", > > > > - len, NAMESIZE, dev->name); > > > > - return -1; > > > > - } > > > > + assert(strlen(dev->name) < NAMESIZE); > > > > > > Aren't you changing the logic here ? > > > > pretty sure it's the same. old code would warn when "len >= max", while > > mine asserts that "len < max" and thus aborts when "!(len < max)" and > > based on boolean logic, "(x >= y) == !(x < y)". > > The old code return -1, doesn't abort ;-) yes, but the old code only executes when there's an error you need to fix. aborting is fine. -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 : http://lists.denx.de/pipermail/u-boot/attachments/20110912/1b71f28e/attachment.pgp