netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <ben.hutchings@mind.be>
To: netdev@vger.kernel.org
Subject: [PATCH iproute2 2/2] devlink: Fix printf() type mismatches on 32-bit architectures
Date: Tue, 29 Jun 2021 01:25:59 +0200	[thread overview]
Message-ID: <20210628232558.GB1443@cephalopod> (raw)
In-Reply-To: <20210628232446.GA1443@cephalopod>

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



  reply	other threads:[~2021-06-28 23:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2021-06-29 18:40 ` 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=20210628232558.GB1443@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).