]> Gentwo Git Trees - linux/.git/commitdiff
tools/nolibc: implement %m if errno is not defined
authorBenjamin Berg <benjamin.berg@intel.com>
Wed, 24 Sep 2025 14:20:52 +0000 (16:20 +0200)
committerThomas Weißschuh <linux@weissschuh.net>
Wed, 29 Oct 2025 15:29:15 +0000 (16:29 +0100)
For improved compatibility, print %m as "unknown error" when nolibc is
compiled using NOLIBC_IGNORE_ERRNO.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
tools/include/nolibc/stdio.h

index 724d05ce69624fe1615b2bd441d403bdfc14c63e..1f16dab2ac8847d1d10af5b06f8b0164354734fd 100644 (file)
@@ -321,11 +321,13 @@ int __nolibc_printf(__nolibc_printf_cb cb, intptr_t state, size_t n, const char
                                if (!outstr)
                                        outstr="(null)";
                        }
-#ifndef NOLIBC_IGNORE_ERRNO
                        else if (c == 'm') {
+#ifdef NOLIBC_IGNORE_ERRNO
+                               outstr = "unknown error";
+#else
                                outstr = strerror(errno);
-                       }
 #endif /* NOLIBC_IGNORE_ERRNO */
+                       }
                        else if (c == '%') {
                                /* queue it verbatim */
                                continue;