]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme, plugins: fix __u64 -> unsigned long long assumptions
authorJeremy Kerr <jk@codeconstruct.com.au>
Mon, 26 Sep 2022 10:04:08 +0000 (18:04 +0800)
committerJeremy Kerr <jk@codeconstruct.com.au>
Mon, 26 Sep 2022 12:31:01 +0000 (20:31 +0800)
We have a couple of instances which assume __u64 is an unsigned long,
which is not always the case.

For the printf() formats, we would ideally used PRId64, but on ll64
platforms, it looks this macro is broken: it expands to "ld", where
__u64 is an unsigned long long. So, do an explicit cast to unsigned long
long instead, and just use %lld.

With this change, we can compile without warnings on amd64, armhf and
powerpc64le.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
nvme.c
plugins/scaleflux/sfx-nvme.c
plugins/seagate/seagate-nvme.c

diff --git a/nvme.c b/nvme.c
index 4658c68bacb975ef0510e0d06b0cceac9c3d49cd..47ce9d6e10df6e6793a7d870d6a3b6517689e2b5 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -5982,7 +5982,7 @@ static int copy(int argc, char **argv, struct command *cmd, struct plugin *plugi
        if (cfg.format == 0)
                nrts = argconfig_parse_comma_sep_array(cfg.eilbrts, (int *)eilbrts.f0, ARRAY_SIZE(eilbrts.f0));
        else if (cfg.format == 1)
-               nrts = argconfig_parse_comma_sep_array_long(cfg.eilbrts, (__u64 *)eilbrts.f1, ARRAY_SIZE(eilbrts.f1));
+               nrts = argconfig_parse_comma_sep_array_long(cfg.eilbrts, (unsigned long long *)eilbrts.f1, ARRAY_SIZE(eilbrts.f1));
        else {
                fprintf(stderr, "invalid format\n");
                err = -EINVAL;
index cd992a1d6a230135894cb37a9e88fef827c01cfd..a776664d8478eaa75d1fd6434a33188aae0ff47e 100644 (file)
@@ -611,7 +611,8 @@ static void show_lat_stats_myrtle(struct sfx_lat_stats_myrtle *stats, int write)
        for (i = 0; i < 64; i++)
                printf("Bucket %2d: %u\n", i, stats->bucket_19[i]);
 
-       printf("\nAverage latency statistics %lld\n", stats->average);
+       printf("\nAverage latency statistics %" PRIu64 "\n",
+              (uint64_t)stats->average);
 }
 
 
index 53a8af899b9fa1085ca6fc7c3813c0c225a4597b..1bd30a5471a154dda60b8b2397ed8b54b01f9965 100644 (file)
@@ -1388,7 +1388,8 @@ static void print_stx_vs_fw_activate_history(stx_fw_activ_history_log_page fwAct
                        ts = *localtime(&t);
                        strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &ts);
                        printf(" %-20s   ", buf);
-                       printf("%-5lld   ", fwActivHis.fwActHisEnt[i].powCycleCnt);
+                       printf("%-5" PRId64 "   ",
+                              (uint64_t)fwActivHis.fwActHisEnt[i].powCycleCnt);
 
                        memset(prev_fw, 0, sizeof(prev_fw));
                        memcpy(prev_fw, fwActivHis.fwActHisEnt[i].previousFW, sizeof(fwActivHis.fwActHisEnt[i].previousFW));