public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] net: turn name len check into an assert
Date: Mon, 12 Sep 2011 12:29:10 -0400	[thread overview]
Message-ID: <201109121229.11257.vapier@gentoo.org> (raw)
In-Reply-To: <201109120708.50484.marek.vasut@gmail.com>

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 

  reply	other threads:[~2011-09-12 16:29 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 [this message]
2011-09-12 17:06     ` Marek Vasut
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=201109121229.11257.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox