The branch main has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=283c1bd8ceb07cbbc5fa3f3034b2e2d9ee53d981

commit 283c1bd8ceb07cbbc5fa3f3034b2e2d9ee53d981
Author:     Konstantin Belousov <k...@freebsd.org>
AuthorDate: 2025-07-03 03:04:23 +0000
Commit:     Konstantin Belousov <k...@freebsd.org>
CommitDate: 2025-07-07 18:44:14 +0000

    uexterr_format(): simplify output when ext error string is available
    
    If the extended error string is provided by kernel, return only the
    string, which is supposedly enough to identify exact cause of the error.
    If the string is not provided, print the technically looking gibberish
    which still allows to identify location with kernel sources.
    
    Reviewed by:    asomers, brooks
    Sponsored by:   The FreeBSD Foundation
    Differential revision:  https://reviews.freebsd.org/D51141
---
 lib/libc/gen/uexterr_format.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/libc/gen/uexterr_format.c b/lib/libc/gen/uexterr_format.c
index 32b57ffb6e1a..86ba40234ae4 100644
--- a/lib/libc/gen/uexterr_format.c
+++ b/lib/libc/gen/uexterr_format.c
@@ -23,9 +23,13 @@ __uexterr_format(const struct uexterror *ue, char *buf, 
size_t bufsz)
                strlcpy(buf, "No error", bufsz);
                return (0);
        }
-       snprintf(buf, bufsz,
-           "errno %d category %u (src line %u) p1 %#jx p2 %#jx %s",
-           ue->error, ue->cat, ue->src_line,
-           (uintmax_t)ue->p1, (uintmax_t)ue->p2, ue->msg);
+       if (ue->msg[0] == '\0') {
+               snprintf(buf, bufsz,
+                   "errno %d category %u (src line %u) p1 %#jx p2 %#jx",
+                   ue->error, ue->cat, ue->src_line,
+                   (uintmax_t)ue->p1, (uintmax_t)ue->p2);
+       } else {
+               strlcpy(buf, ue->msg, bufsz);
+       }
        return (0);
 }

Reply via email to