All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Hutchings <ben.hutchings@mind.be>
To: linux-gpio@vger.kernel.org
Subject: [PATCH libgpiod-v2] gpiomon: Fix format specifier for uint64_t
Date: Wed, 28 Jul 2021 15:13:28 +0200	[thread overview]
Message-ID: <20210728131327.GA14442@cephalopod> (raw)

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

             reply	other threads:[~2021-07-28 13:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-28 13:13 Ben Hutchings [this message]
2021-07-29 14:34 ` [PATCH libgpiod-v2] gpiomon: Fix format specifier for uint64_t Bartosz Golaszewski
2021-07-30 14:12   ` Ben Hutchings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210728131327.GA14442@cephalopod \
    --to=ben.hutchings@mind.be \
    --cc=linux-gpio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.