diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-10-07 09:15:44 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-10-11 16:10:21 +0200 |
commit | 385530342869ce4c6ea7388262bec4a0398b9311 (patch) | |
tree | b9547137bb5d84351f187465b234de5f9cde4060 /src/core/unit-serialize.c | |
parent | 892dc967873cab3b8af158284a524d3148db674a (diff) | |
download | systemd-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/core/unit-serialize.c')
-rw-r--r-- | src/core/unit-serialize.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/core/unit-serialize.c b/src/core/unit-serialize.c index 797bf6c5ce..7fe9f3f231 100644 --- a/src/core/unit-serialize.c +++ b/src/core/unit-serialize.c @@ -849,8 +849,10 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) { fprintf(f, "%s\tMerged into: %s\n", prefix, u->merged_into->id); - else if (u->load_state == UNIT_ERROR) - fprintf(f, "%s\tLoad Error Code: %s\n", prefix, strerror_safe(u->load_error)); + else if (u->load_state == UNIT_ERROR) { + errno = abs(u->load_error); + fprintf(f, "%s\tLoad Error Code: %m\n", prefix); + } for (const char *n = sd_bus_track_first(u->bus_track); n; n = sd_bus_track_next(u->bus_track)) fprintf(f, "%s\tBus Ref: %s\n", prefix, n); |