From: Ben Hutchings <ben.hutchings@mind.be>
To: netdev@vger.kernel.org
Subject: [PATCH iproute2 1/2] utils: Fix BIT() to support up to 64 bits on all architectures
Date: Tue, 29 Jun 2021 01:24:46 +0200 [thread overview]
Message-ID: <20210628232446.GA1443@cephalopod> (raw)
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(-)
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]))
--
2.20.1
next reply other threads:[~2021-06-28 23:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-28 23:24 Ben Hutchings [this message]
2021-06-28 23:25 ` [PATCH iproute2 2/2] devlink: Fix printf() type mismatches on 32-bit architectures Ben Hutchings
2021-06-29 18:40 ` [PATCH iproute2 1/2] utils: Fix BIT() to support up to 64 bits on all architectures patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210628232446.GA1443@cephalopod \
--to=ben.hutchings@mind.be \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).