From: Marek Vasut <marek.vasut@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] net: turn name len check into an assert
Date: Mon, 12 Sep 2011 19:06:13 +0200 [thread overview]
Message-ID: <201109121906.13752.marek.vasut@gmail.com> (raw)
In-Reply-To: <201109121229.11257.vapier@gentoo.org>
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 ;-)
next prev parent reply other threads:[~2011-09-12 17:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-12 4:49 [U-Boot] [PATCH] net: turn name len check into an assert Mike Frysinger
2011-09-12 5:08 ` Marek Vasut
2011-09-12 16:29 ` Mike Frysinger
2011-09-12 17:06 ` Marek Vasut [this message]
2011-09-12 20:24 ` Mike Frysinger
2011-09-21 21:04 ` Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201109121906.13752.marek.vasut@gmail.com \
--to=marek.vasut@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.