Skip to content

Commit ca5b245

Browse files
benzeagregkh
authored andcommitted
tools/nolibc: implement %m if errno is not defined
[ Upstream commit fbd1b7f ] 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> Stable-dep-of: 4045e7b ("tools/nolibc/printf: Move snprintf length check to callback") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 00c0317 commit ca5b245

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tools/include/nolibc/stdio.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,13 @@ int __nolibc_printf(__nolibc_printf_cb cb, intptr_t state, size_t n, const char
321321
if (!outstr)
322322
outstr="(null)";
323323
}
324-
#ifndef NOLIBC_IGNORE_ERRNO
325324
else if (c == 'm') {
325+
#ifdef NOLIBC_IGNORE_ERRNO
326+
outstr = "unknown error";
327+
#else
326328
outstr = strerror(errno);
327-
}
328329
#endif /* NOLIBC_IGNORE_ERRNO */
330+
}
329331
else if (c == '%') {
330332
/* queue it verbatim */
331333
continue;

0 commit comments

Comments
 (0)