* [PATCH v1] net: dev: Use unsigned integer as an argument to left-shift
@ 2019-02-27 10:37 Andy Shevchenko
2019-02-27 17:34 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2019-02-27 10:37 UTC (permalink / raw)
To: David S. Miller, netdev; +Cc: Andy Shevchenko
1 << 31 is Undefined Behaviour according to the C standard.
Use U type modifier to avoid theoretical overflow.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
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 86dbb3e29139..848b54b7ec91 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)
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] net: dev: Use unsigned integer as an argument to left-shift
2019-02-27 10:37 [PATCH v1] net: dev: Use unsigned integer as an argument to left-shift Andy Shevchenko
@ 2019-02-27 17:34 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-02-27 17:34 UTC (permalink / raw)
To: andriy.shevchenko; +Cc: netdev
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Wed, 27 Feb 2019 13:37:26 +0300
> 1 << 31 is Undefined Behaviour according to the C standard.
> Use U type modifier to avoid theoretical overflow.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied, thanks Andy.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-27 17:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-27 10:37 [PATCH v1] net: dev: Use unsigned integer as an argument to left-shift Andy Shevchenko
2019-02-27 17:34 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).