diff options
author | Willy Tarreau <w@1wt.eu> | 2022-02-07 19:23:35 +0300 |
---|---|---|
committer | Paul E. McKenney <paulmck@kernel.org> | 2022-04-21 03:05:44 +0300 |
commit | acab7bcdb1bc14d5a6a0c3c1d2b9bd681172cf47 (patch) | |
tree | 713ed9c0b82fc8ff77b5a921346fcc407413aefd /tools/include/nolibc | |
parent | 51469d5ab38fd1ac2182da8cd49eea3420b8000b (diff) | |
download | linux-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/include/nolibc')
-rw-r--r-- | tools/include/nolibc/stdio.h | 6 |
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 */ |