]> Gentwo Git Trees - linux/.git/commitdiff
tools/nolibc/stdio: let perror work when NOLIBC_IGNORE_ERRNO is set
authorBenjamin Berg <benjamin.berg@intel.com>
Wed, 24 Sep 2025 14:20:50 +0000 (16:20 +0200)
committerThomas Weißschuh <linux@weissschuh.net>
Wed, 29 Oct 2025 15:29:13 +0000 (16:29 +0100)
There is no errno variable when NOLIBC_IGNORE_ERRNO is defined. As such,
simply print the message with "unknown error" rather than the integer
value of errno.

Fixes: acab7bcdb1bc ("tools/nolibc/stdio: add perror() to report the errno value")
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
tools/include/nolibc/stdio.h

index 7630234408c584a560b059f0a7e30d407d186f17..724d05ce69624fe1615b2bd441d403bdfc14c63e 100644 (file)
@@ -600,7 +600,11 @@ int sscanf(const char *str, const char *format, ...)
 static __attribute__((unused))
 void perror(const char *msg)
 {
+#ifdef NOLIBC_IGNORE_ERRNO
+       fprintf(stderr, "%s%sunknown error\n", (msg && *msg) ? msg : "", (msg && *msg) ? ": " : "");
+#else
        fprintf(stderr, "%s%serrno=%d\n", (msg && *msg) ? msg : "", (msg && *msg) ? ": " : "", errno);
+#endif
 }
 
 static __attribute__((unused))