Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: David Binderman <dcb314@hotmail.com>
Cc: "dwmw2@infradead.org" <dwmw2@infradead.org>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>
Subject: Re: linux-next/include/linux/mtd/pfow.h: possible poor sequence of conditionals ?
Date: Sat, 2 Apr 2016 23:27:40 -0700	[thread overview]
Message-ID: <20160403062740.GA21749@localhost> (raw)
In-Reply-To: <DUB128-W1B9618CEFDEE4D2DDF6C89C800@phx.gbl>

On Tue, Mar 22, 2016 at 02:49:06PM +0000, David Binderman wrote:
> Hello there,
> 
> > [linux-next/include/linux/mtd/pfow.h:133]: (style) Expression is always false because 'else if' condition matches previous condition at line 130.
> > [linux-next/include/linux/mtd/pfow.h:136]: (style) Expression is always false because 'else if' condition matches previous condition at line 130.
> 
> Source code is
> 
>     if (prog_status & 0x03)
>         printk(KERN_NOTICE"DSR.9,8: (11) Attempt to program invalid "
>                         "half with 41h command\n");
>     else if (prog_status & 0x02)
>         printk(KERN_NOTICE"DSR.9,8: (10) Object Mode Program attempt "
>                     "in region with Control Mode data\n");
>     else if (prog_status &  0x01)
>         printk(KERN_NOTICE"DSR.9,8: (01) Program attempt in region "
>                         "with Object Mode data\n");
> 
> Maybe something like
> 
>     switch (prog_status & 0x03)
>     {
>         case 0x03:
>             printk(); break;
>         case 0x02:
>             printk(); break;
>         case 0x01:
>             printk(); break;
>     }
> 
> might be better code.

I'm not sure if you're aware of this... but this isn't really a style
issue; it's a correctness issue. I believe the original code is wrong.

Feel free to send a patch, especially if you can test it.

Regards,
Brian

  reply	other threads:[~2016-04-03  6:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-22 14:49 linux-next/include/linux/mtd/pfow.h: possible poor sequence of conditionals ? David Binderman
2016-04-03  6:27 ` Brian Norris [this message]
2016-04-03 15:41   ` David Binderman

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=20160403062740.GA21749@localhost \
    --to=computersforpeace@gmail.com \
    --cc=dcb314@hotmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    /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