]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
utils: Fix BIT() to support up to 64 bits on all architectures
authorBen Hutchings <ben.hutchings@mind.be>
Mon, 28 Jun 2021 23:24:46 +0000 (01:24 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 29 Jun 2021 18:10:14 +0000 (11:10 -0700)
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>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
include/utils.h

index 187444d52b4147156a722c318c7bb87ff16595c4..70db9f609416396bbb2644308636007073043ee0 100644 (file)
@@ -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]))