From 8949ec930a78abcd71a2c3433c7253fc9633853d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Sat, 21 Jan 2023 00:44:14 +0000 Subject: [PATCH] dmesg: use subsecond granularity in iso format MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Weißschuh --- sys-utils/dmesg.c | 8 ++++---- tests/expected/dmesg/indentation | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index fdf0f46314..45075e50bd 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -878,10 +878,10 @@ static char *short_ctime(struct tm *tm, char *buf, size_t bufsiz) static char *iso_8601_time(struct dmesg_control *ctl, struct dmesg_record *rec, char *buf, size_t bufsz) { - struct timeval tv = { - .tv_sec = ctl->boot_time.tv_sec + ctl->suspended_time / USEC_PER_SEC + rec->tv.tv_sec, - .tv_usec = rec->tv.tv_usec - }; + struct timeval tv = usec_to_timeval( + timeval_to_usec(&ctl->boot_time) + ctl->suspended_time + + timeval_to_usec(&rec->tv) + ); if (strtimeval_iso(&tv, ISO_TIMESTAMP_COMMA_T, buf, bufsz) != 0) return NULL; diff --git a/tests/expected/dmesg/indentation b/tests/expected/dmesg/indentation index e1b2770d1c..dc08810c0a 100644 --- a/tests/expected/dmesg/indentation +++ b/tests/expected/dmesg/indentation @@ -28,8 +28,8 @@ lines [Fri Feb 13 23:31:32 2009] two new lines -2009-02-13T23:31:31,000000+00:00 new +2009-02-13T23:31:31,123456+00:00 new line -2009-02-13T23:31:32,000000+00:00 two +2009-02-13T23:31:32,123456+00:00 two new lines -- 2.47.3