* [PATCH] 3c515: fix integer overflow warning
@ 2019-03-19 21:15 Arnd Bergmann
2019-03-19 22:08 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2019-03-19 21:15 UTC (permalink / raw)
To: David S. Miller; +Cc: Arnd Bergmann, netdev, linux-kernel
clang points out a harmless signed integer overflow:
drivers/net/ethernet/3com/3c515.c:1530:66: error: implicit conversion from 'int' to 'short' changes value from 32783 to -32753 [-Werror,-Wconstant-conversion]
new_mode = SetRxFilter | RxStation | RxMulticast | RxBroadcast | RxProm;
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
drivers/net/ethernet/3com/3c515.c:1532:52: error: implicit conversion from 'int' to 'short' changes value from 32775 to -32761 [-Werror,-Wconstant-conversion]
new_mode = SetRxFilter | RxStation | RxMulticast | RxBroadcast;
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
drivers/net/ethernet/3com/3c515.c:1534:38: error: implicit conversion from 'int' to 'short' changes value from 32773 to -32763 [-Werror,-Wconstant-conversion]
new_mode = SetRxFilter | RxStation | RxBroadcast;
~ ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
Make the variable unsigned to avoid the overflow.
Fixes: Linux-2.1.128pre1
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/ethernet/3com/3c515.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/3com/3c515.c b/drivers/net/ethernet/3com/3c515.c
index 808abb6b3671..b15752267c8d 100644
--- a/drivers/net/ethernet/3com/3c515.c
+++ b/drivers/net/ethernet/3com/3c515.c
@@ -1521,7 +1521,7 @@ static void update_stats(int ioaddr, struct net_device *dev)
static void set_rx_mode(struct net_device *dev)
{
int ioaddr = dev->base_addr;
- short new_mode;
+ unsigned short new_mode;
if (dev->flags & IFF_PROMISC) {
if (corkscrew_debug > 3)
--
2.20.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] 3c515: fix integer overflow warning
2019-03-19 21:15 [PATCH] 3c515: fix integer overflow warning Arnd Bergmann
@ 2019-03-19 22:08 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-03-19 22:08 UTC (permalink / raw)
To: arnd; +Cc: netdev, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
Date: Tue, 19 Mar 2019 22:15:58 +0100
> clang points out a harmless signed integer overflow:
>
> drivers/net/ethernet/3com/3c515.c:1530:66: error: implicit conversion from 'int' to 'short' changes value from 32783 to -32753 [-Werror,-Wconstant-conversion]
> new_mode = SetRxFilter | RxStation | RxMulticast | RxBroadcast | RxProm;
> ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
> drivers/net/ethernet/3com/3c515.c:1532:52: error: implicit conversion from 'int' to 'short' changes value from 32775 to -32761 [-Werror,-Wconstant-conversion]
> new_mode = SetRxFilter | RxStation | RxMulticast | RxBroadcast;
> ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
> drivers/net/ethernet/3com/3c515.c:1534:38: error: implicit conversion from 'int' to 'short' changes value from 32773 to -32763 [-Werror,-Wconstant-conversion]
> new_mode = SetRxFilter | RxStation | RxBroadcast;
> ~ ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
>
> Make the variable unsigned to avoid the overflow.
>
> Fixes: Linux-2.1.128pre1
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-19 22:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-19 21:15 [PATCH] 3c515: fix integer overflow warning Arnd Bergmann
2019-03-19 22:08 ` 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).