Skip to contentSkip to conversation

tools/gpio/gpio-event-mon: fix warning

PATCH In review Anders Roxell 3 participants 3 messages Feb 21, 2018 – Mar 1, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/gpio/gpio-event-mon: fix warning

PRIu64 is defined in user space to match libc's uint64_t definition. However, gpioevent_data structure in the kernel is defined using the kernel's own __u64 type.

gpio-event-mon.c: In function ‘monitor_device’:
gpio-event-mon.c:102:19: warning: format ‘%lu’ expects argument of type
‘long unsigned int’, but argument 3 has type ‘__u64 {aka long long unsigned int}’ [-Wformat=]

   fprintf(stdout, "GPIO EVENT %" PRIu64 ": ", event.timestamp);
                   ^~~~~~~~~~~~~~

LD /tmp/kselftest/gpiogpio-event-mon-in.o
LINK /tmp/kselftest/gpiogpio-event-mon

Fix is to replace PRIu64 with llu, which we know is what the kernel uses for __u64.

---
 tools/gpio/gpio-event-mon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/gpio/gpio-event-mon.c +1 -1
index dac4d4131d9b..c864544efe05 100644
@@ -99,7 +99,7 @@ int monitor_device(const char *device_name,
 			ret = -EIO;
 			break;
 		}
-		fprintf(stdout, "GPIO EVENT %" PRIu64 ": ", event.timestamp);
+		fprintf(stdout, "GPIO EVENT %llu: ", event.timestamp);
 		switch (event.id) {
 		case GPIOEVENT_EVENT_RISING_EDGE:
 			fprintf(stdout, "rising edge");
Signature · 1 line
2.11.0
Tested-by on v1 1/1
#1 lore raw
Quoted 10 lines · Anders Roxell

PRIu64 is defined in user space to match libc's uint64_t definition. However, gpioevent_data structure in the kernel is defined using the kernel's own __u64 type.

gpio-event-mon.c: In function ‘monitor_device’:
gpio-event-mon.c:102:19: warning: format ‘%lu’ expects argument of type
‘long unsigned int’, but argument 3 has type ‘__u64 {aka long long unsigned int}’ [-Wformat=]

   fprintf(stdout, "GPIO EVENT %" PRIu64 ": ", event.timestamp);
                   ^~~~~~~~~~~~~~
Quoted 7 lines

LD /tmp/kselftest/gpiogpio-event-mon-in.o
LINK /tmp/kselftest/gpiogpio-event-mon

Fix is to replace PRIu64 with llu, which we know is what the kernel uses for __u64.

Quoted 19 lines
---
 tools/gpio/gpio-event-mon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/gpio/gpio-event-mon.c +1 -2
index dac4d4131d9b..c864544efe05 100644
@@ -99,7 +99,7 @@ int monitor_device(const char *device_name,
                        ret = -EIO;
                        break;
                }
-               fprintf(stdout, "GPIO EVENT %" PRIu64 ": ", event.timestamp);
+               fprintf(stdout, "GPIO EVENT %llu: ", event.timestamp);
                switch (event.id) {
                case GPIOEVENT_EVENT_RISING_EDGE:
                        fprintf(stdout, "rising edge");
--

2.11.0

#2 lore raw
In reply to Anders Roxell
Quoted 10 lines · Anders Roxell

PRIu64 is defined in user space to match libc's uint64_t definition. However, gpioevent_data structure in the kernel is defined using the kernel's own __u64 type.

gpio-event-mon.c: In function ‘monitor_device’:
gpio-event-mon.c:102:19: warning: format ‘%lu’ expects argument of type
‘long unsigned int’, but argument 3 has type ‘__u64 {aka long long unsigned int}’ [-Wformat=]

   fprintf(stdout, "GPIO EVENT %" PRIu64 ": ", event.timestamp);
                   ^~~~~~~~~~~~~~
Quoted 7 lines

LD /tmp/kselftest/gpiogpio-event-mon-in.o
LINK /tmp/kselftest/gpiogpio-event-mon

Fix is to replace PRIu64 with llu, which we know is what the kernel uses for __u64.

Patch applied with Daniel's test tag.

Yours,
Linus Walleij