From 232d65c2329835bd1ca67aba7603c29cf2f5a870 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Tue, 22 Jun 2021 22:26:13 +0800 Subject: [PATCH] net: Fix: left shift of 1 by 31 places cannot be represented in type 'long int' Signed-off-by: Xiang Xiao Change-Id: Id2daa60834f7b1917b15bbad89b091b59311e988 --- net/netdev/netdev_findbyindex.c | 4 ++-- net/netdev/netdev_register.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/netdev/netdev_findbyindex.c b/net/netdev/netdev_findbyindex.c index ebf188b130..1fbef332f0 100644 --- a/net/netdev/netdev_findbyindex.c +++ b/net/netdev/netdev_findbyindex.c @@ -75,7 +75,7 @@ FAR struct net_driver_s *netdev_findbyindex(int ifindex) #ifdef CONFIG_NETDEV_IFINDEX /* Check if this index has been assigned */ - if ((g_devset & (1L << (ifindex - 1))) == 0) + if ((g_devset & (1UL << (ifindex - 1))) == 0) { /* This index has not been assigned */ @@ -142,7 +142,7 @@ int netdev_nextindex(int ifindex) net_lock(); for (; ifindex < MAX_IFINDEX; ifindex++) { - if ((g_devset & (1L << ifindex)) != 0) + if ((g_devset & (1UL << ifindex)) != 0) { /* NOTE that the index + 1 is returned. Zero is reserved to * mean no-index in the POSIX standards. diff --git a/net/netdev/netdev_register.c b/net/netdev/netdev_register.c index 3ce1732fc6..cc70c2afa4 100644 --- a/net/netdev/netdev_register.c +++ b/net/netdev/netdev_register.c @@ -189,7 +189,7 @@ static int get_ifindex(void) for (ndx = 0; ndx < MAX_IFINDEX; ndx++) { - uint32_t bit = 1L << ndx; + uint32_t bit = 1UL << ndx; if ((devset & bit) == 0) { /* Indicate that this index is in use */