Skip to contentSkip to conversation

usb: misc: remove unnecessary code

PATCH In review Gustavo A. R. Silva 2 participants 3 messages Feb 20, 2017 – Feb 22, 2017 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: misc: remove unnecessary code

'val' is an unsigned variable, and less-than-zero comparison of an unsigned variable is never true.

Addresses-Coverity-ID: 1230257

---
 drivers/usb/misc/lvstest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/misc/lvstest.c +1 -1
index c7c2104..6f37610 100644
@@ -193,7 +193,7 @@ static ssize_t u2_timeout_store(struct device *dev,
 		return ret;
 	}
 
-	if (val < 0 || val > 127)
+	if (val > 127)
 		return -EINVAL;
 
 	ret = lvs_rh_set_port_feature(hdev, lvs->portnum | (val << 8),
Signature · 1 line
2.5.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Gustavo A. R. Silva

'val' is an unsigned variable, and less-than-zero comparison of an unsigned variable is never true.

I would add that val is set by kstrtoul() that converts a string to an unsigned long.

Quoted 2 lines

Addresses-Coverity-ID: 1230257

Quoted 21 lines
---
 drivers/usb/misc/lvstest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/misc/lvstest.c +1 -1
index c7c2104..6f37610 100644
@@ -193,7 +193,7 @@ static ssize_t u2_timeout_store(struct device *dev,
 		return ret;
 	}
 
-	if (val < 0 || val > 127)
+	if (val > 127)
 		return -EINVAL;
 
 	ret = lvs_rh_set_port_feature(hdev, lvs->portnum | (val << 8),
Signature · 1 line
2.5.0
#2 lore raw

Hi Peter,

Quoting Peter Senna Tschudin <[email protected]>:

Quoted 23 lines · Gustavo A. R. Silva
Quoted 2 lines

'val' is an unsigned variable, and less-than-zero comparison of an unsigned variable is never true.

I would add that val is set by kstrtoul() that converts a string to an unsigned long.

Quoted 2 lines

Addresses-Coverity-ID: 1230257

Quoted 13 lines
---
 drivers/usb/misc/lvstest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/misc/lvstest.c +0 -0
index c7c2104..6f37610 100644
@@ -193,7 +193,7 @@ static ssize_t u2_timeout_store(struct device *dev,
 		return ret;
 	}
 
Quoted 8 lines
Quoted 8 lines
drivers/usb/misc/lvstest.c +1 -2
-	if (val < 0 || val > 127)
+	if (val > 127)
 		return -EINVAL;
 
 	ret = lvs_rh_set_port_feature(hdev, lvs->portnum | (val << 8),
--

2.5.0

Thanks for your comments.
--
Gustavo A. R. Silva