This Linux kernel change "net: dev: Use unsigned integer as an argument to left-shift" is included in the Linux 5.0 release. This change is authored by Andy Shevchenko <andriy.shevchenko [at] linux.intel.com> on Wed Feb 27 13:37:26 2019 +0300. The commit for this change in Linux stable tree is f4d7b3e (patch).
net: dev: Use unsigned integer as an argument to left-shift 1 << 31 is Undefined Behaviour according to the C standard. Use U type modifier to avoid theoretical overflow. Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.
include/linux/netdevice.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 86dbb3e..848b54b 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3861,7 +3861,7 @@ static inline u32 netif_msg_init(int debug_value, int default_msg_enable_bits) if (debug_value == 0) /* no output */ return 0; /* set low N bits */ - return (1 << debug_value) - 1; + return (1U << debug_value) - 1; } static inline void __netif_tx_lock(struct netdev_queue *txq, int cpu)