]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
devlink: Fix printf() type mismatches on 32-bit architectures
authorBen Hutchings <ben.hutchings@mind.be>
Mon, 28 Jun 2021 23:25:59 +0000 (01:25 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 29 Jun 2021 18:10:14 +0000 (11:10 -0700)
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>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
devlink/devlink.c

index 0b5548fbee98344b9d16dcfb926c0a8d1cb32c0a..5db709cc54d8dfe7fbe99ff690b51a2b77df887f 100644 (file)
@@ -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;