From: Karel Zak Date: Thu, 12 Mar 2026 11:56:14 +0000 (+0100) Subject: dmesg: fix -d -t (--show-delta --notime) output regression X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e795adc5bbbac961e70bb402c9fce2397b059bf6;p=thirdparty%2Futil-linux.git dmesg: fix -d -t (--show-delta --notime) output regression When -d and -t are used together, only the time delta should be printed without the timestamp prefix. This was broken because DMESG_TIMEFTM_NONE in the format list caused the print_record() loop to break early before processing the delta format. Resolve the conflict after option parsing: when NONE coexists with a delta format (TIME_DELTA or DELTA), replace all formats with just DELTA. When NONE is used without delta, it suppresses all timestamps as before. Fixes: https://github.com/util-linux/util-linux/issues/4110 Signed-off-by: Karel Zak --- diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index f4ff3e2c5..5496bdbe4 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -1879,6 +1879,24 @@ int main(int argc, char *argv[]) ctl.suspended_time = dmesg_get_suspended_time(); } + /* + * Resolve NONE (--notime) vs. delta combinations. When both are + * specified (e.g. -d -t), delta wins and timestamp is suppressed. + * When NONE is used without delta, it suppresses all timestamps. + */ + if (is_time_fmt_set(&ctl, DMESG_TIMEFTM_NONE)) { + if (is_time_fmt_set(&ctl, DMESG_TIMEFTM_TIME_DELTA) + || is_time_fmt_set(&ctl, DMESG_TIMEFTM_DELTA)) { + reset_time_fmts(&ctl); + ctl.ntime_fmts = 0; + include_time_fmt(&ctl, DMESG_TIMEFTM_DELTA); + } else { + reset_time_fmts(&ctl); + ctl.ntime_fmts = 0; + include_time_fmt(&ctl, DMESG_TIMEFTM_NONE); + } + } + /* -d uses TIME_DELTA; merge with -T (CTIME) if both specified */ if (is_time_fmt_set(&ctl, DMESG_TIMEFTM_TIME_DELTA) && is_time_fmt_set(&ctl, DMESG_TIMEFTM_CTIME)) {