From: Ben Hutchings Date: Mon, 28 Jun 2021 23:24:46 +0000 (+0200) Subject: utils: Fix BIT() to support up to 64 bits on all architectures X-Git-Tag: v5.13.0~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ac0383a598d4bddf13cbd8272f0ea7711614b79;p=thirdparty%2Fiproute2.git utils: Fix BIT() to support up to 64 bits on all architectures 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 Signed-off-by: Stephen Hemminger --- diff --git a/include/utils.h b/include/utils.h index 187444d52..70db9f609 100644 --- a/include/utils.h +++ b/include/utils.h @@ -8,6 +8,7 @@ #include #include #include +#include #ifdef HAVE_LIBBSD #include @@ -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]))