History

ethtool: silence warning on bit loss

Sparse was complaining when we went to prototype some code using ethtool_cmd_speed_set and SPEED_100000, which uses the upper 16 bits of __u32 speed for the first time. CHECK ... .../uapi/linux/ethtool.h:123:28: warning: cast truncates bits from constant value (186a0 becomes 86a0) The warning is actually bogus, as no bits are really lost, but we can get rid of the sparse warning with this one small change.

Jesse Brandeburg committed 10 years ago

Commit 85a62441 parent 958b3d31 file · +1 −2Browse files

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

Unified · Split

include/uapi/linux/ethtool.h+1−2
@@ -119,8 +119,7 @@ struct ethtool_cmd { · 118 unmodified lines
119119 static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
120120 __u32 speed)
121121 {
122−
123− ep->speed = (__u16)speed;
122+ ep->speed = (__u16)(speed & 0xFFFF);
124123 ep->speed_hi = (__u16)(speed >> 16);
125124 }
126125