]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
dmesg: improve buffer size error message
authorKarel Zak <kzak@redhat.com>
Mon, 16 Feb 2026 09:04:43 +0000 (10:04 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 16 Feb 2026 09:05:04 +0000 (10:05 +0100)
Improve the error message when buffer size is too large to include
the maximum allowed size. This helps users understand what the actual
limit is rather than just reporting an invalid value.

Before: invalid buffer size argument: '...'
After: buffer size ... is too large (maximum is ...)

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

index a0786da2b4c9d5ac2dbafab03ac09790bc773a6c..4a7357d9f46121cd83e69bb79f0ed37c50ffd485 100644 (file)
@@ -1788,8 +1788,9 @@ int main(int argc, char *argv[])
                        if (ctl.bufsize < 4096)
                                ctl.bufsize = 4096;
                        if (ctl.bufsize > SIZE_MAX - 8)
-                               errx(EXIT_FAILURE, "%s: '%s'",
-                                               _("invalid buffer size argument"), optarg);
+                               errx(EXIT_FAILURE,
+                                               _("buffer size %s is too large (maximum is %zu)"),
+                                               optarg, SIZE_MAX - 8);
                        break;
                case 'T':
                        include_time_fmt(&ctl, DMESG_TIMEFTM_CTIME);