diff mbox series

[libgpiod] core: examples: fix warning for u64 formatting on 32bit

Message ID 20230630090858.37485-1-warthog618@gmail.com
State New
Headers show
Series [libgpiod] core: examples: fix warning for u64 formatting on 32bit | expand

Commit Message

Kent Gibson June 30, 2023, 9:08 a.m. UTC
The watch_line_info example prints the u64 timestamps using "%ld" which
produces a warning for 32bit.  Replace it with PRIu64.

Signed-off-by: Kent Gibson <warthog618@gmail.com>
---
 examples/watch_line_info.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Bartosz Golaszewski June 30, 2023, 12:16 p.m. UTC | #1
On Fri, Jun 30, 2023 at 11:09 AM Kent Gibson <warthog618@gmail.com> wrote:
>
> The watch_line_info example prints the u64 timestamps using "%ld" which
> produces a warning for 32bit.  Replace it with PRIu64.
>
> Signed-off-by: Kent Gibson <warthog618@gmail.com>
> ---
>  examples/watch_line_info.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/examples/watch_line_info.c b/examples/watch_line_info.c
> index 1879a62..9df3121 100644
> --- a/examples/watch_line_info.c
> +++ b/examples/watch_line_info.c
> @@ -5,6 +5,7 @@
>
>  #include <errno.h>
>  #include <gpiod.h>
> +#include <inttypes.h>
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
> @@ -63,7 +64,7 @@ int main(void)
>
>                 info = gpiod_info_event_get_line_info(event);
>                 timestamp_ns = gpiod_info_event_get_timestamp_ns(event);
> -               printf("line %3d: %-9s %ld.%ld\n",
> +               printf("line %3d: %-9s %" PRIu64 ".%" PRIu64 "\n",
>                        gpiod_line_info_get_offset(info), event_type(event),
>                        timestamp_ns / 1000000000, timestamp_ns % 1000000000);
>
> --
> 2.41.0
>

Applied, thanks!

Bart
diff mbox series

Patch

diff --git a/examples/watch_line_info.c b/examples/watch_line_info.c
index 1879a62..9df3121 100644
--- a/examples/watch_line_info.c
+++ b/examples/watch_line_info.c
@@ -5,6 +5,7 @@ 
 
 #include <errno.h>
 #include <gpiod.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -63,7 +64,7 @@  int main(void)
 
 		info = gpiod_info_event_get_line_info(event);
 		timestamp_ns = gpiod_info_event_get_timestamp_ns(event);
-		printf("line %3d: %-9s %ld.%ld\n",
+		printf("line %3d: %-9s %" PRIu64 ".%" PRIu64 "\n",
 		       gpiod_line_info_get_offset(info), event_type(event),
 		       timestamp_ns / 1000000000, timestamp_ns % 1000000000);