This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
[glibc] support: Fix timespec printf
- From: Adhemerval Zanella <azanella at sourceware dot org>
- To: glibc-cvs at sourceware dot org
- Date: 10 May 2019 12:40:10 -0000
- Subject: [glibc] support: Fix timespec printf
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=eb669ff5bf2c8093b7e88b75e745ce3f1f4bd8a4
commit eb669ff5bf2c8093b7e88b75e745ce3f1f4bd8a4
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Fri May 10 09:35:18 2019 -0300
support: Fix timespec printf
The patch print timespec members as intmax_t instead of long int.
It avoid the -Werror=format= build issue on x32:
timespec.c: In function 'test_timespec_before_impl':
timespec.c:32:23: error: format '%ld' expects argument of type 'long int',
but argument 4 has type '__time_t' {aka 'const long long int'} [-Werror=format=]
Checked on x86_64-linux-gnu-x32, x86_64-linux-gnu, and i686-linux-gnu.
* support/timespec.c (test_timespec_before_impl,
test_timespec_equal_or_after_impl): print timespec member as intmax_t
insted of long int.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Diff:
---
ChangeLog | 6 ++++++
support/timespec.c | 21 +++++++++++----------
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 47a2a9e..8f6b8c8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-05-09 Adhemerval Zanella <adhemerval.zanella@linaro.org>
+
+ * support/timespec.c (test_timespec_before_impl,
+ test_timespec_equal_or_after_impl): print timespec member as intmax_t
+ insted of long int.
+
2019-05-09 Mike Crowe <mac@mcrowe.com>
* nptl/tst-abstime.c: Use libsupport.
diff --git a/support/timespec.c b/support/timespec.c
index f1b88c1..6532939 100644
--- a/support/timespec.c
+++ b/support/timespec.c
@@ -18,6 +18,7 @@
#include <support/timespec.h>
#include <stdio.h>
+#include <stdint.h>
void
test_timespec_before_impl (const char *file, int line,
@@ -29,12 +30,12 @@ test_timespec_before_impl (const char *file, int line,
&& left.tv_nsec > right.tv_nsec)) {
support_record_failure ();
const struct timespec diff = timespec_sub (left, right);
- printf ("%s:%d: %ld.%09lds not before %ld.%09lds "
- "(difference %ld.%09lds)n",
+ printf ("%s:%d: %jd.%09jds not before %jd.%09jds "
+ "(difference %jd.%09jds)n",
file, line,
- left.tv_sec, left.tv_nsec,
- right.tv_sec, right.tv_nsec,
- diff.tv_sec, diff.tv_nsec);
+ (intmax_t) left.tv_sec, (intmax_t) left.tv_nsec,
+ (intmax_t) right.tv_sec, (intmax_t) right.tv_nsec,
+ (intmax_t) diff.tv_sec, (intmax_t) diff.tv_nsec);
}
}
@@ -48,11 +49,11 @@ test_timespec_equal_or_after_impl (const char *file, int line,
&& left.tv_nsec < right.tv_nsec)) {
support_record_failure ();
const struct timespec diff = timespec_sub (right, left);
- printf ("%s:%d: %ld.%09lds not after %ld.%09lds "
- "(difference %ld.%09lds)n",
+ printf ("%s:%d: %jd.%09jds not after %jd.%09jds "
+ "(difference %jd.%09jds)n",
file, line,
- left.tv_sec, left.tv_nsec,
- right.tv_sec, right.tv_nsec,
- diff.tv_sec, diff.tv_nsec);
+ (intmax_t) left.tv_sec, (intmax_t) left.tv_nsec,
+ (intmax_t) right.tv_sec, (intmax_t) right.tv_nsec,
+ (intmax_t) diff.tv_sec, (intmax_t) diff.tv_nsec);
}
}