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