[U-Boot] [PATCH] net: turn name len check into an assert

Marek Vasut marek.vasut at gmail.com
Mon Sep 12 19:06:13 CEST 2011


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)".
> -mike

The old code return -1, doesn't abort ;-)


More information about the U-Boot mailing list