tools/nolibc: implement %m if errno is not defined

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>
This commit is contained in:
Benjamin Berg
2025-09-24 16:20:52 +02:00
committed by Thomas Weißschuh
parent 4ada5679f1
commit fbd1b7f6b3

View 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;