]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
dmesg: fix delta calculation
authorKarel Zak <kzak@redhat.com>
Tue, 13 Feb 2024 09:56:41 +0000 (10:56 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 13 Feb 2024 09:56:41 +0000 (10:56 +0100)
Old:
./dmesg --nopager --color=never --decode --time-format delta  --kernel --since "@$t"
kern  :info  : [<18446744098961.000000>] bash (40091): drop_caches: 3

Fixed:
./dmesg --nopager --color=never --decode --time-format delta  --kernel --since "@$t"
kern  :info  : [<25251.997673>] bash (40091): drop_caches: 3

Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/dmesg.c

index 3dde45d54b831a8f226fd99ac975834cb7163a16..48282f1e6cc8af02807d6c220b7763b69e408015 100644 (file)
@@ -604,7 +604,7 @@ static const char *parse_kmsg_timestamp(const char *str0, struct timeval *tv)
 
 static double time_diff(struct timeval *a, struct timeval *b)
 {
-       return (a->tv_sec - b->tv_sec) + (a->tv_usec - b->tv_usec) / USEC_PER_SEC;
+       return (a->tv_sec - b->tv_sec) + (a->tv_usec - b->tv_usec) / (double) USEC_PER_SEC;
 }
 
 static int get_syslog_buffer_size(void)