linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH libgpiod-v2] gpiomon: Fix format specifier for uint64_t
@ 2021-07-28 13:13 Ben Hutchings
  2021-07-29 14:34 ` Bartosz Golaszewski
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Hutchings @ 2021-07-28 13:13 UTC (permalink / raw)
  To: linux-gpio

uint64_t might be defined as either unsigned long or unsigned long
long, depending on the architecture.  Values of this type should be
formatted with the specifier PRIu64 rather than "ld".

Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
---
 tools/gpiomon.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/gpiomon.c b/tools/gpiomon.c
index 2b5966c..df86a46 100644
--- a/tools/gpiomon.c
+++ b/tools/gpiomon.c
@@ -4,6 +4,7 @@
 #include <errno.h>
 #include <getopt.h>
 #include <gpiod.h>
+#include <inttypes.h>
 #include <limits.h>
 #include <poll.h>
 #include <signal.h>
@@ -95,10 +96,10 @@ static void event_print_custom(unsigned int offset, uint64_t timeout,
 				fputc('0', stdout);
 			break;
 		case 's':
-			printf("%ld", timeout / 1000000000);
+			printf("%"PRIu64, timeout / 1000000000);
 			break;
 		case 'n':
-			printf("%ld", timeout % 1000000000);
+			printf("%"PRIu64, timeout % 1000000000);
 			break;
 		case '%':
 			fputc('%', stdout);
@@ -129,7 +130,7 @@ static void event_print_human_readable(unsigned int offset,
 	else
 		evname = "FALLING EDGE";
 
-	printf("event: %s offset: %u timestamp: [%8ld.%09ld]\n",
+	printf("event: %s offset: %u timestamp: [%8"PRIu64".%09"PRIu64"]\n",
 	       evname, offset, timeout / 1000000000, timeout % 1000000000);
 }
 
-- 
2.20.1

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

end of thread, other threads:[~2021-07-30 14:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-28 13:13 [PATCH libgpiod-v2] gpiomon: Fix format specifier for uint64_t Ben Hutchings
2021-07-29 14:34 ` Bartosz Golaszewski
2021-07-30 14:12   ` Ben Hutchings

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).