* [PATCH] net: wimax: i2400m: control.c: Cleaning up conjunction always evaluates to false
@ 2014-06-07 11:26 Rickard Strandqvist
2014-06-07 11:42 ` Joe Perches
2014-06-11 7:15 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Rickard Strandqvist @ 2014-06-07 11:26 UTC (permalink / raw)
To: Inaky Perez-Gonzalez, linux-wimax
Cc: Rickard Strandqvist, netdev, linux-kernel
Logical conjunction always evaluates to false: minor < 2 && minor > 1
I guess what you wanted is rather: minor > 2 || minor < 1
This was partly found using a static code analysis program called cppcheck.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
drivers/net/wimax/i2400m/control.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wimax/i2400m/control.c b/drivers/net/wimax/i2400m/control.c
index 4a01e5c..4c41790 100644
--- a/drivers/net/wimax/i2400m/control.c
+++ b/drivers/net/wimax/i2400m/control.c
@@ -1061,7 +1061,7 @@ int i2400m_firmware_check(struct i2400m *i2400m)
goto error_bad_major;
}
result = 0;
- if (minor < I2400M_HDIv_MINOR_2 && minor > I2400M_HDIv_MINOR)
+ if (minor > I2400M_HDIv_MINOR_2 || minor < I2400M_HDIv_MINOR)
dev_warn(dev, "untested minor fw version %u.%u.%u\n",
major, minor, branch);
/* Yes, we ignore the branch -- we don't have to track it */
--
1.7.10.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: wimax: i2400m: control.c: Cleaning up conjunction always evaluates to false
2014-06-07 11:26 [PATCH] net: wimax: i2400m: control.c: Cleaning up conjunction always evaluates to false Rickard Strandqvist
@ 2014-06-07 11:42 ` Joe Perches
2014-06-07 11:52 ` Rickard Strandqvist
2014-06-11 7:15 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Joe Perches @ 2014-06-07 11:42 UTC (permalink / raw)
To: Rickard Strandqvist
Cc: Inaky Perez-Gonzalez, linux-wimax, netdev, linux-kernel
On Sat, 2014-06-07 at 13:26 +0200, Rickard Strandqvist wrote:
> Logical conjunction always evaluates to false: minor < 2 && minor > 1
> I guess what you wanted is rather: minor > 2 || minor < 1
[]
> diff --git a/drivers/net/wimax/i2400m/control.c b/drivers/net/wimax/i2400m/control.c
[]
> @@ -1061,7 +1061,7 @@ int i2400m_firmware_check(struct i2400m *i2400m)
> goto error_bad_major;
> }
> result = 0;
> - if (minor < I2400M_HDIv_MINOR_2 && minor > I2400M_HDIv_MINOR)
> + if (minor > I2400M_HDIv_MINOR_2 || minor < I2400M_HDIv_MINOR)
perhaps clearer as:
if (!(minor == I2400M_HDIv_MINOR || minor == I2400M_HDIv_MINOR_2))
> dev_warn(dev, "untested minor fw version %u.%u.%u\n",
> major, minor, branch);
> /* Yes, we ignore the branch -- we don't have to track it */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: wimax: i2400m: control.c: Cleaning up conjunction always evaluates to false
2014-06-07 11:42 ` Joe Perches
@ 2014-06-07 11:52 ` Rickard Strandqvist
0 siblings, 0 replies; 4+ messages in thread
From: Rickard Strandqvist @ 2014-06-07 11:52 UTC (permalink / raw)
To: Joe Perches
Cc: Inaky Perez-Gonzalez, linux-wimax, Network Development, linux-kernel
Hi
Thought about it, and now it becomes clearer.
But if someone decides to change the X or Y to a larger range than 1
and 2, it will not be correct ..?
Or, will it not happen?
But I'm no expert on this code :)
I just wanted to point out the logical error.
Best regards
Rickard Strandqvist
2014-06-07 13:42 GMT+02:00 Joe Perches <joe@perches.com>:
> On Sat, 2014-06-07 at 13:26 +0200, Rickard Strandqvist wrote:
>> Logical conjunction always evaluates to false: minor < 2 && minor > 1
>> I guess what you wanted is rather: minor > 2 || minor < 1
> []
>> diff --git a/drivers/net/wimax/i2400m/control.c b/drivers/net/wimax/i2400m/control.c
> []
>> @@ -1061,7 +1061,7 @@ int i2400m_firmware_check(struct i2400m *i2400m)
>> goto error_bad_major;
>> }
>> result = 0;
>> - if (minor < I2400M_HDIv_MINOR_2 && minor > I2400M_HDIv_MINOR)
>> + if (minor > I2400M_HDIv_MINOR_2 || minor < I2400M_HDIv_MINOR)
>
> perhaps clearer as:
>
> if (!(minor == I2400M_HDIv_MINOR || minor == I2400M_HDIv_MINOR_2))
>
>> dev_warn(dev, "untested minor fw version %u.%u.%u\n",
>> major, minor, branch);
>> /* Yes, we ignore the branch -- we don't have to track it */
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: wimax: i2400m: control.c: Cleaning up conjunction always evaluates to false
2014-06-07 11:26 [PATCH] net: wimax: i2400m: control.c: Cleaning up conjunction always evaluates to false Rickard Strandqvist
2014-06-07 11:42 ` Joe Perches
@ 2014-06-11 7:15 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2014-06-11 7:15 UTC (permalink / raw)
To: rickard_strandqvist
Cc: inaky.perez-gonzalez, linux-wimax, netdev, linux-kernel
From: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Date: Sat, 7 Jun 2014 13:26:37 +0200
> Logical conjunction always evaluates to false: minor < 2 && minor > 1
> I guess what you wanted is rather: minor > 2 || minor < 1
>
> This was partly found using a static code analysis program called cppcheck.
>
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-06-11 7:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-07 11:26 [PATCH] net: wimax: i2400m: control.c: Cleaning up conjunction always evaluates to false Rickard Strandqvist
2014-06-07 11:42 ` Joe Perches
2014-06-07 11:52 ` Rickard Strandqvist
2014-06-11 7:15 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®