dcavalca / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone
2d8d482
From d91fd10aaee61ae9281f96f0661d2a3564ed4274 Mon Sep 17 00:00:00 2001
2d8d482
From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
2d8d482
Date: Wed, 22 Mar 2017 21:34:32 +0100
2d8d482
Subject: [PATCH] journal/journald-console: fix format-specifier issue
2d8d482
2d8d482
timespec::tv_nsec can have different sizes depending on the
2d8d482
host architecture. On x32 in particular, it is 8 bytes long
2d8d482
while the long int type is only 4 bytes long. Hence, using
2d8d482
ld as a format specifier will trigger a format error. Thus,
2d8d482
explicitly cast timespec::tv_nsec to nsec_t and use PRI_NSEC
2d8d482
as the format specifier to make sure the sizes for both match.
2d8d482
2d8d482
(cherry picked from commit b123d975ca50c5b44adaeb407cfd7da36c123b03)
2d8d482
---
2d8d482
 src/journal/journald-console.c | 4 ++--
2d8d482
 1 file changed, 2 insertions(+), 2 deletions(-)
2d8d482
2d8d482
diff --git a/src/journal/journald-console.c b/src/journal/journald-console.c
2d8d482
index 5126c2160e..5fbcdb43c2 100644
2d8d482
--- a/src/journal/journald-console.c
2d8d482
+++ b/src/journal/journald-console.c
2d8d482
@@ -72,9 +72,9 @@ void server_forward_console(
2d8d482
         /* First: timestamp */
2d8d482
         if (prefix_timestamp()) {
2d8d482
                 assert_se(clock_gettime(CLOCK_MONOTONIC, &ts) == 0);
2d8d482
-                xsprintf(tbuf, "[%5"PRI_TIME".%06ld] ",
2d8d482
+                xsprintf(tbuf, "[%5"PRI_TIME".%06"PRI_NSEC"] ",
2d8d482
                          ts.tv_sec,
2d8d482
-                         ts.tv_nsec / 1000);
2d8d482
+                         (nsec_t)ts.tv_nsec / 1000);
2d8d482
                 IOVEC_SET_STRING(iovec[n++], tbuf);
2d8d482
         }
2d8d482