* linux-next/include/linux/mtd/pfow.h: possible poor sequence of conditionals ?
@ 2016-03-22 14:49 David Binderman
2016-04-03 6:27 ` Brian Norris
0 siblings, 1 reply; 3+ messages in thread
From: David Binderman @ 2016-03-22 14:49 UTC (permalink / raw)
To: dwmw2, computersforpeace, linux-mtd
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.
Regards
David Binderman
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: linux-next/include/linux/mtd/pfow.h: possible poor sequence of conditionals ?
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
2016-04-03 15:41 ` David Binderman
0 siblings, 1 reply; 3+ messages in thread
From: Brian Norris @ 2016-04-03 6:27 UTC (permalink / raw)
To: David Binderman; +Cc: dwmw2, linux-mtd
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: linux-next/include/linux/mtd/pfow.h: possible poor sequence of conditionals ?
2016-04-03 6:27 ` Brian Norris
@ 2016-04-03 15:41 ` David Binderman
0 siblings, 0 replies; 3+ messages in thread
From: David Binderman @ 2016-04-03 15:41 UTC (permalink / raw)
To: Brian Norris; +Cc: dwmw2, linux-mtd
Hello there,
----------------------------------------
> 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.
Thanks for the information.
> Feel free to send a patch, especially if you can test it.
Sorry no, I am unable to send a patch. I am happy for someone else
more capable to send in a patch.
Regards
David Binderman
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-04-03 15:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2016-04-03 15:41 ` David Binderman
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.