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