Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools: gpio: fix %llu warning in gpio-watch.c

Some platforms, such as mips64, don't map __u64 to long long unsigned
int so using %llu produces a warning:

gpio-watch.c: In function ‘main’:
gpio-watch.c:89:30: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
89 | printf("line %u: %s at %llu\n",
| ~~~^
| |
| long long unsigned int
| %lu
90 | chg.info.offset, event, chg.timestamp_ns);
| ~~~~~~~~~~~~~~~~
| |
| __u64 {aka long unsigned int}

Replace the %llu with PRIu64 and cast the argument to uint64_t.

Fixes: 33f0c47b8fb4 ("tools: gpio: implement gpio-watch")
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

authored by

Kent Gibson and committed by
Bartosz Golaszewski
1fc7c1ef 2fe7c2f9

+3 -2
+3 -2
tools/gpio/gpio-watch.c
··· 10 10 #include <ctype.h> 11 11 #include <errno.h> 12 12 #include <fcntl.h> 13 + #include <inttypes.h> 13 14 #include <linux/gpio.h> 14 15 #include <poll.h> 15 16 #include <stdbool.h> ··· 87 86 return EXIT_FAILURE; 88 87 } 89 88 90 - printf("line %u: %s at %llu\n", 91 - chg.info.offset, event, chg.timestamp_ns); 89 + printf("line %u: %s at %" PRIu64 "\n", 90 + chg.info.offset, event, (uint64_t)chg.timestamp_ns); 92 91 } 93 92 } 94 93