summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2022-02-07 19:23:35 +0300
committerPaul E. McKenney <paulmck@kernel.org>2022-04-21 03:05:44 +0300
commitacab7bcdb1bc14d5a6a0c3c1d2b9bd681172cf47 (patch)
tree713ed9c0b82fc8ff77b5a921346fcc407413aefd /tools
parent51469d5ab38fd1ac2182da8cd49eea3420b8000b (diff)
downloadlinux-acab7bcdb1bc14d5a6a0c3c1d2b9bd681172cf47.tar.xz
tools/nolibc/stdio: add perror() to report the errno value
It doesn't contain the text for the error codes, but instead displays "errno=" followed by the errno value. Just like the regular errno, if a non-empty message is passed, it's placed followed with ": " on the output before the errno code. The message is emitted on stderr. Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/include/nolibc/stdio.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h
index a73cf24cb68d..5f1cf32470d3 100644
--- a/tools/include/nolibc/stdio.h
+++ b/tools/include/nolibc/stdio.h
@@ -286,4 +286,10 @@ int printf(const char *fmt, ...)
return ret;
}
+static __attribute__((unused))
+void perror(const char *msg)
+{
+ fprintf(stderr, "%s%serrno=%d\n", (msg && *msg) ? msg : "", (msg && *msg) ? ": " : "", errno);
+}
+
#endif /* _NOLIBC_STDIO_H */