summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-10-07 09:15:44 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-10-11 16:10:21 +0200
commit385530342869ce4c6ea7388262bec4a0398b9311 (patch)
treeb9547137bb5d84351f187465b234de5f9cde4060 /src/journal
parent892dc967873cab3b8af158284a524d3148db674a (diff)
downloadsystemd-385530342869ce4c6ea7388262bec4a0398b9311.tar.gz
core,logind,systemctl,journald: replace calls to strerror() with setting errno + %m
strerror() is not thread safe and calling it just isn't worth the effort required to justify why it would be safe in those cases. It's easier to just use %m which is thread-safe out of the box. I don't think that any of the changes in the patch cause any functional difference. This is just about getting rid of calls to strerror() in general. When we print an error message and fail to format the string, using something like "(null)" is good enough. This is very very unlikely to happen anyway.
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/journald-server.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index bfa9f44a83..71d7a59bda 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -1094,7 +1094,8 @@ void server_driver_message(Server *s, pid_t object_pid, const char *message_id,
/* We failed to format the message. Emit a warning instead. */
char buf[LINE_MAX];
- xsprintf(buf, "MESSAGE=Entry printing failed: %s", strerror_safe(r));
+ errno = -r;
+ xsprintf(buf, "MESSAGE=Entry printing failed: %m");
n = 3;
iovec[n++] = IOVEC_MAKE_STRING("PRIORITY=4");