]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
timesync/timesyncd-manager: fix format-specifier issues
authorMatija Skala <mskala@gmx.com>
Fri, 19 May 2017 12:36:12 +0000 (14:36 +0200)
committerJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Fri, 19 May 2017 12:38:25 +0000 (14:38 +0200)
timex::time::tv_usec and timex::freq can have different sizes
depending on the host architecture. On x32 in particular,
it is 8 bytes long while the long int type is only 4 bytes
long. Hence, using li as a format specifier will trigger
a format error. Thus, introduce a new format specifier
PRI_TIMEX which is defined as PRIi64 on x32 and li
everywhere else.

src/basic/format-util.h
src/timesync/timesyncd-manager.c

index 39a185f59b4affffedc8044b556a4ab019edcd95..ae42a8f89e8ca87d32898c3c7bb05af1616b01dc 100644 (file)
 #  error Unknown time_t size
 #endif
 
+#if defined __x86_64__ && defined __ILP32__
+#  define PRI_TIMEX PRIi64
+#else
+#  define PRI_TIMEX "li"
+#endif
+
 #if SIZEOF_RLIM_T == 8
 #  define RLIM_FMT "%" PRIu64
 #elif SIZEOF_RLIM_T == 4
index 6a6c1577c64de84287b98f2903babb0e2d3db2d2..11c495e29188c79b1068f3e1fe5b4dcbfa3f1f68 100644 (file)
@@ -379,9 +379,9 @@ static int manager_adjust_clock(Manager *m, double offset, int leap_sec) {
 
         log_debug("  status       : %04i %s\n"
                   "  time now     : %li.%03"PRI_USEC"\n"
-                  "  constant     : %li\n"
+                  "  constant     : %"PRI_TIMEX"\n"
                   "  offset       : %+.3f sec\n"
-                  "  freq offset  : %+li (%i ppm)\n",
+                  "  freq offset  : %+"PRI_TIMEX" (%i ppm)\n",
                   tmx.status, tmx.status & STA_UNSYNC ? "unsync" : "sync",
                   tmx.time.tv_sec, tmx.time.tv_usec / NSEC_PER_MSEC,
                   tmx.constant,