All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2 1/2] utils: Fix BIT() to support up to 64 bits on all architectures
@ 2021-06-28 23:24 Ben Hutchings
  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
  0 siblings, 2 replies; 3+ messages in thread
From: Ben Hutchings @ 2021-06-28 23:24 UTC (permalink / raw
  To: netdev

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH iproute2 2/2] devlink: Fix printf() type mismatches on 32-bit architectures
  2021-06-28 23:24 [PATCH iproute2 1/2] utils: Fix BIT() to support up to 64 bits on all architectures Ben Hutchings
@ 2021-06-28 23:25 ` 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
  1 sibling, 0 replies; 3+ messages in thread
From: Ben Hutchings @ 2021-06-28 23:25 UTC (permalink / raw
  To: netdev

devlink currently uses "%lu" to format values of type uint64_t,
but on 32-bit architectures uint64_t is defined as unsigned
long long and this does not work correctly.

Fix this by using the standard macro PRIu64 instead.

Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
---
 devlink/devlink.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 0b5548fb..5db709cc 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -3546,7 +3546,7 @@ static int cmd_dev_flash_status_cb(const struct nlmsghdr *nlh, void *data)
 		}
 	}
 	if (total) {
-		pr_out_tty(" %3lu%%", (done * 100) / total);
+		pr_out_tty(" %3"PRIu64"%%", (done * 100) / total);
 		ctx->last_pc = 1;
 	} else {
 		ctx->last_pc = 0;
@@ -3601,7 +3601,7 @@ static void cmd_dev_flash_time_elapsed(struct cmd_dev_flash_status_ctx *ctx)
 		 */
 		if (!ctx->status_msg_timeout) {
 			len = snprintf(msg, sizeof(msg),
-				       " ( %lum %lus )", elapsed_m, elapsed_s);
+				       " ( %"PRIu64"m %"PRIu64"s )", elapsed_m, elapsed_s);
 		} else if (res.tv_sec <= ctx->status_msg_timeout) {
 			uint64_t timeout_m, timeout_s;
 
@@ -3609,11 +3609,11 @@ static void cmd_dev_flash_time_elapsed(struct cmd_dev_flash_status_ctx *ctx)
 			timeout_s = ctx->status_msg_timeout % 60;
 
 			len = snprintf(msg, sizeof(msg),
-				       " ( %lum %lus : %lum %lus )",
+				       " ( %"PRIu64"m %"PRIu64"s : %"PRIu64"m %"PRIu64"s )",
 				       elapsed_m, elapsed_s, timeout_m, timeout_s);
 		} else {
 			len = snprintf(msg, sizeof(msg),
-				       " ( %lum %lus : timeout reached )", elapsed_m, elapsed_s);
+				       " ( %"PRIu64"m %"PRIu64"s : timeout reached )", elapsed_m, elapsed_s);
 		}
 
 		ctx->elapsed_time_msg_len = len;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH iproute2 1/2] utils: Fix BIT() to support up to 64 bits on all architectures
  2021-06-28 23:24 [PATCH iproute2 1/2] utils: Fix BIT() to support up to 64 bits on all architectures Ben Hutchings
  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 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-06-29 18:40 UTC (permalink / raw
  To: Ben Hutchings; +Cc: netdev

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-29 18:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-28 23:24 [PATCH iproute2 1/2] utils: Fix BIT() to support up to 64 bits on all architectures Ben Hutchings
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.