Skip to content

Commit afd5ec6

Browse files
benzeaopsiff
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> (cherry picked from commit 6135d225cca7dc04031145207cd1c39d7117cd4e) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 690fabc commit afd5ec6

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

tools/include/nolibc/stdio.h

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

358362
static __attribute__((unused))

0 commit comments

Comments
 (0)