From ddb558e87f96aac76c7d38701e61e89583d651a5 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 3 Feb 2025 11:29:44 +0100
Subject: [PATCH] dmesg: fix --notime use

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>

Reference:https://github.com/util-linux/util-linux/commit/ddb558e87f96aac76c7d38701e61e89583d651a5
Conflict:context adapt
---
 sys-utils/dmesg.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index 5c58010..3c883a8 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -752,11 +752,7 @@ static int get_next_syslog_record(struct dmesg_control *ctl,
 		if (*begin == '[' && (*(begin + 1) == ' ' ||
 				      isdigit(*(begin + 1)))) {
 
-			if (!is_timefmt(ctl, 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++;
 		}
@@ -1205,10 +1201,7 @@ static int parse_kmsg_record(struct dmesg_control *ctl,
 		goto mesg;
 
 	/* C) timestamp */
-	if (is_timefmt(ctl, 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;
 
-- 
2.33.0

