History

ethtool: avoid signed-unsigned comparison in ethtool_validate_speed()

When building C++ userspace code that includes ethtool.h with "-Werror -Wall", g++ complains about signed-unsigned comparison in ethtool_validate_speed() due to definition of SPEED_UNKNOWN as -1. Explicitly cast SPEED_UNKNOWN to __u32 to match type of ethtool_validate_speed() argument.

Michael Zhivich committed 7 years ago

Commit afe64241 parent 3c5189a1 file · +1 −1Browse files

Showing the changes to include/uapi/linux (1 of 1 file). Show all

Unified · Split

include/uapi/linux/ethtool.h+1−1
@@ -1591,7 +1591,7 @@ enum ethtool_link_mode_bit_indices { · 1590 unmodified lines
15911591
15921592 static inline int ethtool_validate_speed(__u32 speed)
15931593 {
1594− return speed <= INT_MAX || speed == SPEED_UNKNOWN;
1594+ return speed <= INT_MAX || speed == (__u32)SPEED_UNKNOWN;
15951595 }
15961596
15971597 /* Duplex, half or full. */