|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
From e7327ee6a1c1bc10afa422587f4d7716f04f32bc 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:40:51 +0100
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
Subject: [PATCH] udev/udevadm-monitor: 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 cc9211b030c1fa7dd8d0e14df1de3e2aba32e50c)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
src/udev/udevadm-monitor.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/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
index f631834341..94a59186ed 100644
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
--- a/src/udev/udevadm-monitor.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+++ b/src/udev/udevadm-monitor.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
@@ -41,9 +41,9 @@ static void print_device(struct udev_device *device, const char *source, int pro
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
struct timespec ts;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
assert_se(clock_gettime(CLOCK_MONOTONIC, &ts) == 0);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
- printf("%-6s[%"PRI_TIME".%06ld] %-8s %s (%s)\n",
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ printf("%-6s[%"PRI_TIME".%06"PRI_NSEC"] %-8s %s (%s)\n",
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
source,
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
- ts.tv_sec, ts.tv_nsec/1000,
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ ts.tv_sec, (nsec_t)ts.tv_nsec/1000,
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
udev_device_get_action(device),
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
udev_device_get_devpath(device),
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
udev_device_get_subsystem(device));
|