From ae1c64ac92eaec24781dc6e099292ffb2d810442 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 3 Mar 2023 23:46:34 +0000 Subject: [PATCH] Slightly simplify perror(). Using %m is slightly less code, and means that perror() wouldn't touch the strerror buffer in TLS. Doesn't matter, but noticed while I was looking at this for another reason, and since it's _less_ code... Test: treehugger Change-Id: I99d31a5c326962958ad843ec4da2c3cc3b93b048 --- libc/stdio/stdio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp index 4f12fd030..645aefa23 100644 --- a/libc/stdio/stdio.cpp +++ b/libc/stdio/stdio.cpp @@ -884,7 +884,7 @@ wint_t getwchar() { void perror(const char* msg) { if (msg == nullptr) msg = ""; - fprintf(stderr, "%s%s%s\n", msg, (*msg == '\0') ? "" : ": ", strerror(errno)); + fprintf(stderr, "%s%s%m\n", msg, (*msg == '\0') ? "" : ": "); } int printf(const char* fmt, ...) {