|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
From 589fa9087a49e4250099bb6a4cf00358379fa3a4 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
From: Matija Skala <mskala@gmx.com>
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
Date: Fri, 19 May 2017 14:36:12 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
Subject: [PATCH] timesync/timesyncd-manager: fix format-specifier issues
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
timex::time::tv_usec and timex::freq can have different sizes
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
depending on the host architecture. On x32 in particular,
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
it is 8 bytes long while the long int type is only 4 bytes
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
long. Hence, using li as a format specifier will trigger
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
a format error. Thus, introduce a new format specifier
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
PRI_TIMEX which is defined as PRIi64 on x32 and li
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
everywhere else.
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
(cherry picked from commit 3bd7ef833caae7431a9c50450ce7b303234d45eb)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
src/basic/format-util.h | 6 ++++++
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
src/timesync/timesyncd-manager.c | 4 ++--
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
2 files changed, 8 insertions(+), 2 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
diff --git a/src/basic/format-util.h b/src/basic/format-util.h
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
index 39a185f59b..ae42a8f89e 100644
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
--- a/src/basic/format-util.h
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+++ b/src/basic/format-util.h
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
@@ -54,6 +54,12 @@
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
# error Unknown time_t size
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
#endif
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+#if defined __x86_64__ && defined __ILP32__
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+# define PRI_TIMEX PRIi64
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+#else
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+# define PRI_TIMEX "li"
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+#endif
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
#if SIZEOF_RLIM_T == 8
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
# define RLIM_FMT "%" PRIu64
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
#elif SIZEOF_RLIM_T == 4
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
index 6a6c1577c6..11c495e291 100644
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
--- a/src/timesync/timesyncd-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+++ b/src/timesync/timesyncd-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
@@ -379,9 +379,9 @@ static int manager_adjust_clock(Manager *m, double offset, int leap_sec) {
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
log_debug(" status : %04i %s\n"
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
" time now : %li.%03"PRI_USEC"\n"
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
- " constant : %li\n"
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ " constant : %"PRI_TIMEX"\n"
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
" offset : %+.3f sec\n"
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
- " freq offset : %+li (%i ppm)\n",
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ " freq offset : %+"PRI_TIMEX" (%i ppm)\n",
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
tmx.status, tmx.status & STA_UNSYNC ? "unsync" : "sync",
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
tmx.time.tv_sec, tmx.time.tv_usec / NSEC_PER_MSEC,
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
tmx.constant,
|