Re: [PATCH] tools/gpio/gpio-event-mon: fix warning
From: Daniel DÃaz RodrÃguez
Date: Wed Feb 21 2018 - 16:42:37 EST
On 21 February 2018 at 15:33, Anders Roxell <anders.roxell@xxxxxxxxxx> wrote:
> 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.
>
> Signed-off-by: Anders Roxell <anders.roxell@xxxxxxxxxx>
Tested-by: Daniel DÃaz <daniel.diaz@xxxxxxxxxx>
> ---
> tools/gpio/gpio-event-mon.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/gpio/gpio-event-mon.c b/tools/gpio/gpio-event-mon.c
> index dac4d4131d9b..c864544efe05 100644
> --- a/tools/gpio/gpio-event-mon.c
> +++ b/tools/gpio/gpio-event-mon.c
> @@ -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