diff mbox series

[iproute2,1/2] utils: Fix BIT() to support up to 64 bits on all architectures

Message ID 20210628232446.GA1443@cephalopod
State New
Headers show
Series [iproute2,1/2] utils: Fix BIT() to support up to 64 bits on all architectures | expand

Commit Message

Ben Hutchings June 28, 2021, 11:24 p.m. UTC
devlink and vdpa use BIT() together with 64-bit flag fields.  devlink
is already using bit numbers greater than 31 and so does not work
correctly on 32-bit architectures.

Fix this by making BIT() use uint64_t instead of unsigned long.

Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
---
 include/utils.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

patchwork-bot+netdevbpf@kernel.org June 29, 2021, 6:40 p.m. UTC | #1
Hello:

This series was applied to iproute2/iproute2.git (refs/heads/main):

On Tue, 29 Jun 2021 01:24:46 +0200 you wrote:
> devlink and vdpa use BIT() together with 64-bit flag fields.  devlink

> is already using bit numbers greater than 31 and so does not work

> correctly on 32-bit architectures.

> 

> Fix this by making BIT() use uint64_t instead of unsigned long.

> 

> Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>

> 

> [...]


Here is the summary with links:
  - [iproute2,1/2] utils: Fix BIT() to support up to 64 bits on all architectures
    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=4ac0383a598d
  - [iproute2,2/2] devlink: Fix printf() type mismatches on 32-bit architectures
    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=33cf9306c824

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/include/utils.h b/include/utils.h
index 187444d5..70db9f60 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -8,6 +8,7 @@ 
 #include <stdlib.h>
 #include <stdbool.h>
 #include <time.h>
+#include <stdint.h>
 
 #ifdef HAVE_LIBBSD
 #include <bsd/string.h>
@@ -264,7 +265,7 @@  void print_nlmsg_timestamp(FILE *fp, const struct nlmsghdr *n);
 unsigned int print_name_and_link(const char *fmt,
 				 const char *name, struct rtattr *tb[]);
 
-#define BIT(nr)                 (1UL << (nr))
+#define BIT(nr)                 (UINT64_C(1) << (nr))
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))