[PATCH net-next] uapi: fix signess in ethtool_validate_speed()

Subsystems: networking [ethtool], networking [general], the rest

STALE3502d

2 messages, 2 authors, 2017-01-20 · open the first message on its own page

[PATCH net-next] uapi: fix signess in ethtool_validate_speed()

From: Volodymyr Bendiuga <hidden>
Date: 2017-01-20 13:21:50

From: Jonas Johansson <redacted>

There is a comparison of speed  variable which
is unsigned, and SPEED_UNKNOWN which is signed.

Signed-off-by: Jonas Johansson <redacted>
Signed-off-by: Volodymyr Bendiuga <redacted>
---
 include/uapi/linux/ethtool.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index f0db778..1ca4a77 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -1500,7 +1500,7 @@ enum ethtool_link_mode_bit_indices {
 
 #define SPEED_UNKNOWN		-1
 
-static inline int ethtool_validate_speed(__u32 speed)
+static inline int ethtool_validate_speed(__s32 speed)
 {
 	return speed <= INT_MAX || speed == SPEED_UNKNOWN;
 }
-- 
2.7.4

Re: [PATCH net-next] uapi: fix signess in ethtool_validate_speed()

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: 2017-01-20 16:36:46

On Fri, Jan 20, 2017 at 02:20:53PM +0100, Volodymyr Bendiuga wrote:
From: Jonas Johansson <redacted>

There is a comparison of speed  variable which
is unsigned, and SPEED_UNKNOWN which is signed.
So?
quoted hunk
Signed-off-by: Jonas Johansson <redacted>
Signed-off-by: Volodymyr Bendiuga <redacted>
---
 include/uapi/linux/ethtool.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index f0db778..1ca4a77 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -1500,7 +1500,7 @@ enum ethtool_link_mode_bit_indices {
 
 #define SPEED_UNKNOWN		-1
 
-static inline int ethtool_validate_speed(__u32 speed)
+static inline int ethtool_validate_speed(__s32 speed)
 {
 	return speed <= INT_MAX || speed == SPEED_UNKNOWN;
 }
Then comparison to INT_MAX does not make sense.
-- 
2.7.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help