Skip to content

Commit 5aea021

Browse files
authored
Merge pull request #186 from igaw/print-format-specifier
src: Use PRIu64 format specifier for uint64 types
2 parents 7e42d89 + 3acfca0 commit 5aea021

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>
@@ -791,7 +792,7 @@ int nvmf_get_discovery_log(nvme_ctrl_t c, struct nvmf_discovery_log **logp,
791792
}
792793

793794
genctr = le64_to_cpu(log->genctr);
794-
nvme_msg(LOG_DEBUG, "%s: discover genctr %lu, retry\n",
795+
nvme_msg(LOG_DEBUG, "%s: discover genctr %" PRIu64 ", retry\n",
795796
name, genctr);
796797
ret = nvme_discovery_log(nvme_ctrl_get_fd(c), hdr, log, true);
797798
if (ret) {
@@ -808,7 +809,7 @@ int nvmf_get_discovery_log(nvme_ctrl_t c, struct nvmf_discovery_log **logp,
808809
errno = EAGAIN;
809810
ret = -1;
810811
} else if (numrec != le64_to_cpu(log->numrec)) {
811-
nvme_msg(LOG_INFO, "%s: could only fetch %lu of %lu records\n",
812+
nvme_msg(LOG_INFO, "%s: could only fetch %" PRIu64 " of %" PRIu64 " records\n",
812813
name, numrec, le64_to_cpu(log->numrec));
813814
errno = EBADSLT;
814815
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)