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