* [PATCH] Doc: networking: txtimestamp: fix printf format warning
@ 2015-06-03 19:38 Frans Klaver
2015-06-04 17:36 ` Richard Cochran
0 siblings, 1 reply; 3+ messages in thread
From: Frans Klaver @ 2015-06-03 19:38 UTC (permalink / raw)
To: Jonathan Corbet; +Cc: linux-doc, linux-kernel, Frans Klaver
Documentation/networking/timestamping/txtimestamp.c: In function ‘__print_timestamp’:
Documentation/networking/timestamping/txtimestamp.c:99:3: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int64_t’ [-Wformat=]
fprintf(stderr, " (%+ld us)", cur_ms - prev_ms);
int64_t differs per platform, so a cast is required.
Signed-off-by: Frans Klaver <fransklaver@gmail.com>
---
Documentation/networking/timestamping/txtimestamp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Documentation/networking/timestamping/txtimestamp.c b/Documentation/networking/timestamping/txtimestamp.c
index 8217510..2d107c1 100644
--- a/Documentation/networking/timestamping/txtimestamp.c
+++ b/Documentation/networking/timestamping/txtimestamp.c
@@ -96,7 +96,8 @@ static void __print_timestamp(const char *name, struct timespec *cur,
prev_ms = (long) ts_prev.tv_sec * 1000 * 1000;
prev_ms += ts_prev.tv_nsec / 1000;
- fprintf(stderr, " (%+ld us)", cur_ms - prev_ms);
+ fprintf(stderr, " (%+lld us)",
+ (long long int)(cur_ms - prev_ms));
}
ts_prev = *cur;
--
2.4.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Doc: networking: txtimestamp: fix printf format warning
2015-06-03 19:38 [PATCH] Doc: networking: txtimestamp: fix printf format warning Frans Klaver
@ 2015-06-04 17:36 ` Richard Cochran
2015-06-04 18:05 ` Frans Klaver
0 siblings, 1 reply; 3+ messages in thread
From: Richard Cochran @ 2015-06-04 17:36 UTC (permalink / raw)
To: Frans Klaver; +Cc: Jonathan Corbet, linux-doc, linux-kernel
On Wed, Jun 03, 2015 at 09:38:39PM +0200, Frans Klaver wrote:
> Documentation/networking/timestamping/txtimestamp.c: In function ‘__print_timestamp’:
> Documentation/networking/timestamping/txtimestamp.c:99:3: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int64_t’ [-Wformat=]
> fprintf(stderr, " (%+ld us)", cur_ms - prev_ms);
>
> int64_t differs per platform, so a cast is required.
No cast is needed. Use PRId64 in the format string instead.
Thanks,
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Doc: networking: txtimestamp: fix printf format warning
2015-06-04 17:36 ` Richard Cochran
@ 2015-06-04 18:05 ` Frans Klaver
0 siblings, 0 replies; 3+ messages in thread
From: Frans Klaver @ 2015-06-04 18:05 UTC (permalink / raw)
To: Richard Cochran; +Cc: Jonathan Corbet, linux-doc, linux-kernel
On 4 June 2015 19:36:12 CEST, Richard Cochran <richardcochran@gmail.com> wrote:
>On Wed, Jun 03, 2015 at 09:38:39PM +0200, Frans Klaver wrote:
>> Documentation/networking/timestamping/txtimestamp.c: In function
>‘__print_timestamp’:
>> Documentation/networking/timestamping/txtimestamp.c:99:3: warning:
>format ‘%ld’ expects argument of type ‘long int’, but argument 3 has
>type ‘int64_t’ [-Wformat=]
>> fprintf(stderr, " (%+ld us)", cur_ms - prev_ms);
>>
>> int64_t differs per platform, so a cast is required.
>
>No cast is needed. Use PRId64 in the format string instead.
Wow, I can't believe I've never run into those...
Will resend.
Thanks,
Frans
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-06-04 18:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-03 19:38 [PATCH] Doc: networking: txtimestamp: fix printf format warning Frans Klaver
2015-06-04 17:36 ` Richard Cochran
2015-06-04 18:05 ` Frans Klaver
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®