From: Jeremy Kerr Date: Mon, 26 Sep 2022 10:04:08 +0000 (+0800) Subject: nvme, plugins: fix __u64 -> unsigned long long assumptions X-Git-Tag: v2.2~25^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=86de51a9ef5310b77725dc6bacbcb3103edf201a;p=users%2Fsagi%2Fnvme-cli.git nvme, plugins: fix __u64 -> unsigned long long assumptions 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 --- diff --git a/nvme.c b/nvme.c index 4658c68b..47ce9d6e 100644 --- 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; diff --git a/plugins/scaleflux/sfx-nvme.c b/plugins/scaleflux/sfx-nvme.c index cd992a1d..a776664d 100644 --- a/plugins/scaleflux/sfx-nvme.c +++ b/plugins/scaleflux/sfx-nvme.c @@ -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); } diff --git a/plugins/seagate/seagate-nvme.c b/plugins/seagate/seagate-nvme.c index 53a8af89..1bd30a54 100644 --- a/plugins/seagate/seagate-nvme.c +++ b/plugins/seagate/seagate-nvme.c @@ -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));