Skip to content

Commit 5bfe033

Browse files
benzeagregkh
authored andcommitted
tools/nolibc/stdio: let perror work when NOLIBC_IGNORE_ERRNO is set
[ Upstream commit c485ca3 ] 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: acab7bc ("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>
1 parent d6bec89 commit 5bfe033

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tools/include/nolibc/stdio.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,11 @@ int printf(const char *fmt, ...)
351351
static __attribute__((unused))
352352
void perror(const char *msg)
353353
{
354+
#ifdef NOLIBC_IGNORE_ERRNO
355+
fprintf(stderr, "%s%sunknown error\n", (msg && *msg) ? msg : "", (msg && *msg) ? ": " : "");
356+
#else
354357
fprintf(stderr, "%s%serrno=%d\n", (msg && *msg) ? msg : "", (msg && *msg) ? ": " : "", errno);
358+
#endif
355359
}
356360

357361
static __attribute__((unused))

0 commit comments

Comments
 (0)