]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
dmesg: fix --notime use
authorKarel Zak <kzak@redhat.com>
Mon, 3 Feb 2025 10:29:44 +0000 (11:29 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 3 Feb 2025 10:29:44 +0000 (11:29 +0100)
The --notime command line option disables parsing of timestamps from
kmsg. This is a bug because the timestamps can be used for operations
other than just output. For example, they can be used for filters like
--since (dmesg --since '1 day ago' --notime).

Addresses: https://github.com/util-linux/util-linux/issues/3392
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/dmesg.c

index 0b1a1681b005fadc4c308b61f964a1512adb61f4..75ca4b6881f8f8294271341c379dbb03fcf4fbd3 100644 (file)
@@ -920,11 +920,7 @@ static int get_next_syslog_record(struct dmesg_control *ctl,
                if (*begin == '[' && (*(begin + 1) == ' ' ||
                                      isdigit(*(begin + 1)))) {
 
-                       if (!is_time_fmt_set(ctl, DMESG_TIMEFTM_NONE))
-                               begin = parse_syslog_timestamp(begin + 1, &rec->tv);
-                       else
-                               begin = skip_item(begin, end, "]");
-
+                       begin = parse_syslog_timestamp(begin + 1, &rec->tv);
                        if (begin < end && *begin == ' ')
                                begin++;
                }
@@ -1461,10 +1457,7 @@ static int parse_kmsg_record(struct dmesg_control *ctl,
                goto mesg;
 
        /* C) timestamp */
-       if (is_time_fmt_set(ctl, DMESG_TIMEFTM_NONE))
-               p = skip_item(p, end, ",;");
-       else
-               p = parse_kmsg_timestamp(p, &rec->tv);
+       p = parse_kmsg_timestamp(p, &rec->tv);
        if (LAST_KMSG_FIELD(p))
                goto mesg;