* [PATCH][next] net: phy: bcm54140: fix less than zero comparison on an unsigned
@ 2020-04-23 14:10 Colin King
2020-04-23 14:37 ` Andrew Lunn
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Colin King @ 2020-04-23 14:10 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, Heiner Kallweit, Russell King,
David S . Miller, Michael Walle, Guenter Roeck, netdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently the unsigned variable tmp is being checked for an negative
error return from the call to bcm_phy_read_rdb and this can never
be true since tmp is unsigned. Fix this by making tmp a plain int.
Addresses-Coverity: ("Unsigned compared against 0")
Fixes: 4406d36dfdf1 ("net: phy: bcm54140: add hwmon support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/phy/bcm54140.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/bcm54140.c b/drivers/net/phy/bcm54140.c
index aa854477e06a..7341f0126cc4 100644
--- a/drivers/net/phy/bcm54140.c
+++ b/drivers/net/phy/bcm54140.c
@@ -191,7 +191,8 @@ static int bcm54140_hwmon_read_alarm(struct device *dev, unsigned int bit,
static int bcm54140_hwmon_read_temp(struct device *dev, u32 attr, long *val)
{
struct phy_device *phydev = dev_get_drvdata(dev);
- u16 reg, tmp;
+ u16 reg;
+ int tmp;
switch (attr) {
case hwmon_temp_input:
@@ -224,7 +225,8 @@ static int bcm54140_hwmon_read_in(struct device *dev, u32 attr,
int channel, long *val)
{
struct phy_device *phydev = dev_get_drvdata(dev);
- u16 bit, reg, tmp;
+ u16 bit, reg;
+ int tmp;
switch (attr) {
case hwmon_in_input:
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH][next] net: phy: bcm54140: fix less than zero comparison on an unsigned
2020-04-23 14:10 [PATCH][next] net: phy: bcm54140: fix less than zero comparison on an unsigned Colin King
@ 2020-04-23 14:37 ` Andrew Lunn
2020-04-23 14:38 ` Colin Ian King
2020-04-23 14:48 ` Michael Walle
2020-04-23 22:57 ` David Miller
2 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2020-04-23 14:37 UTC (permalink / raw)
To: Colin King
Cc: Florian Fainelli, Heiner Kallweit, Russell King,
David S . Miller, Michael Walle, Guenter Roeck, netdev,
kernel-janitors, linux-kernel
On Thu, Apr 23, 2020 at 03:10:16PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the unsigned variable tmp is being checked for an negative
> error return from the call to bcm_phy_read_rdb and this can never
> be true since tmp is unsigned. Fix this by making tmp a plain int.
>
> Addresses-Coverity: ("Unsigned compared against 0")
I thought 0 was unsigned?
> Fixes: 4406d36dfdf1 ("net: phy: bcm54140: add hwmon support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][next] net: phy: bcm54140: fix less than zero comparison on an unsigned
2020-04-23 14:37 ` Andrew Lunn
@ 2020-04-23 14:38 ` Colin Ian King
0 siblings, 0 replies; 5+ messages in thread
From: Colin Ian King @ 2020-04-23 14:38 UTC (permalink / raw)
To: Andrew Lunn
Cc: Florian Fainelli, Heiner Kallweit, Russell King,
David S . Miller, Michael Walle, Guenter Roeck, netdev,
kernel-janitors, linux-kernel
On 23/04/2020 15:37, Andrew Lunn wrote:
> On Thu, Apr 23, 2020 at 03:10:16PM +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Currently the unsigned variable tmp is being checked for an negative
>> error return from the call to bcm_phy_read_rdb and this can never
>> be true since tmp is unsigned. Fix this by making tmp a plain int.
>>
>> Addresses-Coverity: ("Unsigned compared against 0")
>
> I thought 0 was unsigned?
yeah, misleading message from the static analyzer methinks
>
>> Fixes: 4406d36dfdf1 ("net: phy: bcm54140: add hwmon support")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
>
> Andrew
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][next] net: phy: bcm54140: fix less than zero comparison on an unsigned
2020-04-23 14:10 [PATCH][next] net: phy: bcm54140: fix less than zero comparison on an unsigned Colin King
2020-04-23 14:37 ` Andrew Lunn
@ 2020-04-23 14:48 ` Michael Walle
2020-04-23 22:57 ` David Miller
2 siblings, 0 replies; 5+ messages in thread
From: Michael Walle @ 2020-04-23 14:48 UTC (permalink / raw)
To: Colin King
Cc: Andrew Lunn, Florian Fainelli, Heiner Kallweit, Russell King,
David S . Miller, Guenter Roeck, netdev, kernel-janitors,
linux-kernel
Am 2020-04-23 16:10, schrieb Colin King:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the unsigned variable tmp is being checked for an negative
> error return from the call to bcm_phy_read_rdb and this can never
> be true since tmp is unsigned. Fix this by making tmp a plain int.
>
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: 4406d36dfdf1 ("net: phy: bcm54140: add hwmon support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
FWIW since Andrew already reviewed it:
Reviewed-by: Michael Walle <michael@walle.cc>
-michael
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][next] net: phy: bcm54140: fix less than zero comparison on an unsigned
2020-04-23 14:10 [PATCH][next] net: phy: bcm54140: fix less than zero comparison on an unsigned Colin King
2020-04-23 14:37 ` Andrew Lunn
2020-04-23 14:48 ` Michael Walle
@ 2020-04-23 22:57 ` David Miller
2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2020-04-23 22:57 UTC (permalink / raw)
To: colin.king
Cc: andrew, f.fainelli, hkallweit1, linux, michael, linux, netdev,
kernel-janitors, linux-kernel
From: Colin King <colin.king@canonical.com>
Date: Thu, 23 Apr 2020 15:10:16 +0100
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the unsigned variable tmp is being checked for an negative
> error return from the call to bcm_phy_read_rdb and this can never
> be true since tmp is unsigned. Fix this by making tmp a plain int.
>
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: 4406d36dfdf1 ("net: phy: bcm54140: add hwmon support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Applied.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-04-23 22:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-23 14:10 [PATCH][next] net: phy: bcm54140: fix less than zero comparison on an unsigned Colin King
2020-04-23 14:37 ` Andrew Lunn
2020-04-23 14:38 ` Colin Ian King
2020-04-23 14:48 ` Michael Walle
2020-04-23 22:57 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).