[U-Boot] [PATCH] net: turn name len check into an assert
Mike Frysinger
vapier at gentoo.org
Mon Sep 12 18:29:10 CEST 2011
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)".
-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/7705650c/attachment.pgp
More information about the U-Boot
mailing list