[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220207162354.14293-24-w@1wt.eu>
Date: Mon, 7 Feb 2022 17:23:35 +0100
From: Willy Tarreau <w@....eu>
To: "Paul E . McKenney" <paulmck@...nel.org>
Cc: Mark Brown <broonie@...nel.org>, linux-kernel@...r.kernel.org,
Willy Tarreau <w@....eu>
Subject: [PATCH 23/42] 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@....eu>
---
tools/include/nolibc/stdio.h | 6 ++++++
1 file changed, 6 insertions(+)
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 */
--
2.35.1
Powered by blists - more mailing lists