diff options
| author | Benjamin Berg <benjamin.berg@intel.com> | 2025-09-24 16:20:50 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-01-11 15:18:20 +0100 |
| commit | 2e6e013a73973213dfdd77c95b06e5614941a585 (patch) | |
| tree | 96a3f83edee825712f6dac1076aa5183b13b06f3 /tools | |
| parent | 14f295909d643587963be832c4f80389234c09ca (diff) | |
tools/nolibc/stdio: let perror work when NOLIBC_IGNORE_ERRNO is set
[ Upstream commit c485ca3aff2442adea4c08ceb5183e671ebed22a ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/include/nolibc/stdio.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h index 96ac8afc5aee..64dcdfbbe3d9 100644 --- a/tools/include/nolibc/stdio.h +++ b/tools/include/nolibc/stdio.h @@ -300,7 +300,11 @@ int printf(const char *fmt, ...) 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 } /* make sure to include all global symbols */ |
