Skip to content

Commit 3acfca0

Browse files
committed
src: Use PRIu64 format specifier for uint64 types
When compiling for 32bit architectures the compiler is complaining about the wrong format specifier for uint64. Use the the PRIu64 format specifier in this case which is supported from 32bit and 64bit. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 609e6fa commit 3acfca0

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

examples/display-columnar.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* column format for easy visual scanning.
1212
*/
1313
#include <stdio.h>
14+
#include <inttypes.h>
1415
#include <libnvme.h>
1516

1617
static const char dash[101] = {[0 ... 99] = '-'};
@@ -90,7 +91,7 @@ int main()
9091
nvme_for_each_subsystem(h, s) {
9192
nvme_subsystem_for_each_ctrl(s, c) {
9293
nvme_ctrl_for_each_ns(c, n)
93-
printf("%-12s %-8d %-16lu %-8d %s\n",
94+
printf("%-12s %-8d %-16" PRIu64 " %-8d %s\n",
9495
nvme_ns_get_name(n),
9596
nvme_ns_get_nsid(n),
9697
nvme_ns_get_lba_count(n),
@@ -101,7 +102,7 @@ int main()
101102
nvme_subsystem_for_each_ns(s, n) {
102103
bool first = true;
103104

104-
printf("%-12s %-8d %-16lu %-8d ",
105+
printf("%-12s %-8d %-16" PRIu64 " %-8d ",
105106
nvme_ns_get_name(n),
106107
nvme_ns_get_nsid(n),
107108
nvme_ns_get_lba_count(n),

src/nvme/fabrics.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <string.h>
1919
#include <unistd.h>
2020
#include <dirent.h>
21+
#include <inttypes.h>
2122

2223
#include <sys/stat.h>
2324
#include <sys/types.h>
@@ -778,7 +779,7 @@ int nvmf_get_discovery_log(nvme_ctrl_t c, struct nvmf_discovery_log **logp,
778779
}
779780

780781
genctr = le64_to_cpu(log->genctr);
781-
nvme_msg(LOG_DEBUG, "%s: discover genctr %lu, retry\n",
782+
nvme_msg(LOG_DEBUG, "%s: discover genctr %" PRIu64 ", retry\n",
782783
name, genctr);
783784
ret = nvme_discovery_log(nvme_ctrl_get_fd(c), hdr, log, true);
784785
if (ret) {
@@ -795,7 +796,7 @@ int nvmf_get_discovery_log(nvme_ctrl_t c, struct nvmf_discovery_log **logp,
795796
errno = EAGAIN;
796797
ret = -1;
797798
} else if (numrec != le64_to_cpu(log->numrec)) {
798-
nvme_msg(LOG_INFO, "%s: could only fetch %lu of %lu records\n",
799+
nvme_msg(LOG_INFO, "%s: could only fetch %" PRIu64 " of %" PRIu64 " records\n",
799800
name, numrec, le64_to_cpu(log->numrec));
800801
errno = EBADSLT;
801802
ret = -1;

test/test.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <stdio.h>
1919
#include <string.h>
2020
#include <stdbool.h>
21+
#include <inttypes.h>
2122
#ifdef CONFIG_LIBUUID
2223
#include <uuid/uuid.h>
2324
#endif
@@ -274,7 +275,8 @@ static int test_namespace(nvme_ns_t n)
274275
return ret;
275276

276277
nvme_id_ns_flbas_to_lbaf_inuse(ns.flbas, &flbas);
277-
printf("%s: nsze:%lx lba size:%d\n", nvme_ns_get_name(n), le64_to_cpu(ns.nsze),
278+
printf("%s: nsze:%" PRIu64 " lba size:%d\n",
279+
nvme_ns_get_name(n), le64_to_cpu(ns.nsze),
278280
1 << ns.lbaf[flbas].ds);
279281

280282
ret = nvme_identify_allocated_ns(fd, nsid, &allocated);
@@ -367,7 +369,7 @@ int main(int argc, char **argv)
367369
char uuid_str[40];
368370
uuid_t uuid;
369371
#endif
370-
printf(" `- %s lba size:%d lba max:%lu\n",
372+
printf(" `- %s lba size:%d lba max:%" PRIu64 "\n",
371373
nvme_ns_get_name(n),
372374
nvme_ns_get_lba_size(n),
373375
nvme_ns_get_lba_count(n));
@@ -390,7 +392,7 @@ int main(int argc, char **argv)
390392
}
391393

392394
nvme_subsystem_for_each_ns(s, n) {
393-
printf(" `- %s lba size:%d lba max:%lu\n",
395+
printf(" `- %s lba size:%d lba max:%" PRIu64 "\n",
394396
nvme_ns_get_name(n),
395397
nvme_ns_get_lba_size(n),
396398
nvme_ns_get_lba_count(n));

0 commit comments

Comments
 (0)