]> git.ipfire.org Git - thirdparty/systemd.git/commit
tree-wide: use ERRNO_NAME almost everywhere
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 29 Jul 2025 15:59:04 +0000 (17:59 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 29 Jul 2025 16:05:20 +0000 (18:05 +0200)
commit858cb6e49eed26f51dc7e2dc7c4c75664b360e73
tree11e39d77eaf99fa1f8b33bfc42661e875da1c625
parent225450d043bfa5a9814c6ec7fa18d16ce28c6fa7
tree-wide: use ERRNO_NAME almost everywhere

We had errno_to_name() which works for "known" errnos, and returns NULL for
unknown ones, and then ERRNO_NAME which always returns an answer, possibly just
a number as a string, but requires a helper buffer.

It is possible for the kernel to add a new errno. We recently learned that some
architectures define custom errno names. Or for some function to unexpectedly
return a bogus errno value. In almost all cases it's better to print that value
rather than "n/a" or "(null)". So let's use ERRNO_NAME is most error handling
code. Noteably, our code wasn't very good in handling the potential NULL, so
in various places we could print "(null)". Since this is supposed to be used
most of the time, let's shorten the names to ERRNO_NAME/errno_name.

There are a few places where we don't want to use the fallback path, in
particular for D-Bus error names or when saving the error name. Let's rename
errno_to_name() to errno_name_no_fallback() to make the distinction clearer.
22 files changed:
src/basic/errno-list.c
src/basic/errno-list.h
src/core/socket.c
src/home/homed-home.c
src/libsystemd/sd-bus/bus-error.c
src/libsystemd/sd-bus/test-bus-error.c
src/libsystemd/sd-login/test-login.c
src/libsystemd/sd-varlink/sd-varlink.c
src/resolve/resolvectl.c
src/resolve/resolved-dns-transaction.c
src/shared/seccomp-util.c
src/shared/tests.h
src/test/test-bpf-devices.c
src/test/test-bus-unit-util.c
src/test/test-errno-list.c
src/test/test-nss-hosts.c
src/test/test-nss-users.c
src/test/test-process-util.c
src/test/test-stat-util.c
src/udev/udev-error.c
src/udev/udev-worker.c
src/userdb/userdbctl.c