linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] tools: gpio: fix %llu warnings
@ 2021-01-07  4:00 Kent Gibson
  2021-01-07  4:00 ` [PATCH 1/2] tools: gpio: fix %llu warning in gpio-event-mon.c Kent Gibson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kent Gibson @ 2021-01-07  4:00 UTC (permalink / raw)
  To: linux-kernel, linux-gpio, bgolaszewski, linus.walleij; +Cc: Kent Gibson

Fix a couple of warnings that I ran across while testing selftest changes.

Sorry about the repetition in the checkin comments, but as the problem was
introduced to the two files separately it seemed more appropriate than
tying their history together.

Cheers,
Kent.

Kent Gibson (2):
  tools: gpio: fix %llu warning in gpio-event-mon.c
  tools: gpio: fix %llu warning in gpio-watch.c

 tools/gpio/gpio-event-mon.c | 4 ++--
 tools/gpio/gpio-watch.c     | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

-- 
2.30.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] tools: gpio: fix %llu warning in gpio-event-mon.c
  2021-01-07  4:00 [PATCH 0/2] tools: gpio: fix %llu warnings Kent Gibson
@ 2021-01-07  4:00 ` Kent Gibson
  2021-01-07  4:00 ` [PATCH 2/2] tools: gpio: fix %llu warning in gpio-watch.c Kent Gibson
  2021-01-11  9:59 ` [PATCH 0/2] tools: gpio: fix %llu warnings Bartosz Golaszewski
  2 siblings, 0 replies; 4+ messages in thread
From: Kent Gibson @ 2021-01-07  4:00 UTC (permalink / raw)
  To: linux-kernel, linux-gpio, bgolaszewski, linus.walleij; +Cc: Kent Gibson

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

gpio-event-mon.c:110:37: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
  110 |   fprintf(stdout, "GPIO EVENT at %llu on line %d (%d|%d) ",
      |                                  ~~~^
      |                                     |
      |                                     long long unsigned int
      |                                  %lu
  111 |    event.timestamp_ns, event.offset, event.line_seqno,
      |    ~~~~~~~~~~~~~~~~~~
      |         |
      |         __u64 {aka long unsigned int}

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

Fixes: commit 03fd11b03362 ("tools/gpio/gpio-event-mon: fix warning")
Signed-off-by: Kent Gibson <warthog618@gmail.com>
---
 tools/gpio/gpio-event-mon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/gpio/gpio-event-mon.c b/tools/gpio/gpio-event-mon.c
index cacd66ad7926..a2b233fdb572 100644
--- a/tools/gpio/gpio-event-mon.c
+++ b/tools/gpio/gpio-event-mon.c
@@ -107,8 +107,8 @@ int monitor_device(const char *device_name,
 			ret = -EIO;
 			break;
 		}
-		fprintf(stdout, "GPIO EVENT at %llu on line %d (%d|%d) ",
-			event.timestamp_ns, event.offset, event.line_seqno,
+		fprintf(stdout, "GPIO EVENT at %" PRIu64 " on line %d (%d|%d) ",
+			(uint64_t)event.timestamp_ns, event.offset, event.line_seqno,
 			event.seqno);
 		switch (event.id) {
 		case GPIO_V2_LINE_EVENT_RISING_EDGE:
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] tools: gpio: fix %llu warning in gpio-watch.c
  2021-01-07  4:00 [PATCH 0/2] tools: gpio: fix %llu warnings Kent Gibson
  2021-01-07  4:00 ` [PATCH 1/2] tools: gpio: fix %llu warning in gpio-event-mon.c Kent Gibson
@ 2021-01-07  4:00 ` Kent Gibson
  2021-01-11  9:59 ` [PATCH 0/2] tools: gpio: fix %llu warnings Bartosz Golaszewski
  2 siblings, 0 replies; 4+ messages in thread
From: Kent Gibson @ 2021-01-07  4:00 UTC (permalink / raw)
  To: linux-kernel, linux-gpio, bgolaszewski, linus.walleij; +Cc: Kent Gibson

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: commit 33f0c47b8fb4 ("tools: gpio: implement gpio-watch")
Signed-off-by: Kent Gibson <warthog618@gmail.com>
---
 tools/gpio/gpio-watch.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/gpio/gpio-watch.c b/tools/gpio/gpio-watch.c
index f229ec62301b..41e76d244192 100644
--- a/tools/gpio/gpio-watch.c
+++ b/tools/gpio/gpio-watch.c
@@ -10,6 +10,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <inttypes.h>
 #include <linux/gpio.h>
 #include <poll.h>
 #include <stdbool.h>
@@ -86,8 +87,8 @@ int main(int argc, char **argv)
 				return EXIT_FAILURE;
 			}
 
-			printf("line %u: %s at %llu\n",
-			       chg.info.offset, event, chg.timestamp_ns);
+			printf("line %u: %s at %" PRIu64 "\n",
+			       chg.info.offset, event, (uint64_t)chg.timestamp_ns);
 		}
 	}
 
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] tools: gpio: fix %llu warnings
  2021-01-07  4:00 [PATCH 0/2] tools: gpio: fix %llu warnings Kent Gibson
  2021-01-07  4:00 ` [PATCH 1/2] tools: gpio: fix %llu warning in gpio-event-mon.c Kent Gibson
  2021-01-07  4:00 ` [PATCH 2/2] tools: gpio: fix %llu warning in gpio-watch.c Kent Gibson
@ 2021-01-11  9:59 ` Bartosz Golaszewski
  2 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2021-01-11  9:59 UTC (permalink / raw)
  To: Kent Gibson; +Cc: LKML, linux-gpio, Linus Walleij

On Thu, Jan 7, 2021 at 5:00 AM Kent Gibson <warthog618@gmail.com> wrote:
>
> Fix a couple of warnings that I ran across while testing selftest changes.
>
> Sorry about the repetition in the checkin comments, but as the problem was
> introduced to the two files separately it seemed more appropriate than
> tying their history together.
>
> Cheers,
> Kent.
>
> Kent Gibson (2):
>   tools: gpio: fix %llu warning in gpio-event-mon.c
>   tools: gpio: fix %llu warning in gpio-watch.c
>
>  tools/gpio/gpio-event-mon.c | 4 ++--
>  tools/gpio/gpio-watch.c     | 5 +++--
>  2 files changed, 5 insertions(+), 4 deletions(-)
>
> --
> 2.30.0
>

Applied both patches for fixes.

Thanks!
Bartosz

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-11 10:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-07  4:00 [PATCH 0/2] tools: gpio: fix %llu warnings Kent Gibson
2021-01-07  4:00 ` [PATCH 1/2] tools: gpio: fix %llu warning in gpio-event-mon.c Kent Gibson
2021-01-07  4:00 ` [PATCH 2/2] tools: gpio: fix %llu warning in gpio-watch.c Kent Gibson
2021-01-11  9:59 ` [PATCH 0/2] tools: gpio: fix %llu warnings Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).