summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2014-11-28 11:58:34 +0100
committerMichal Schmidt <mschmidt@redhat.com>2014-11-28 12:04:41 +0100
commit0a1beeb64207eaa88ab9236787b1cbc2f704ae14 (patch)
tree50117277be2e2078d0373b944a30b4f09bb94443 /src
parentb4d23205f238e06aaa31264628e20669e714acad (diff)
treewide: auto-convert the simple cases to log_*_errno()
As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
Diffstat (limited to 'src')
-rw-r--r--src/ac-power/ac-power.c2
-rw-r--r--src/activate/activate.c2
-rw-r--r--src/analyze/analyze-verify.c8
-rw-r--r--src/analyze/analyze.c2
-rw-r--r--src/backlight/backlight.c8
-rw-r--r--src/binfmt/binfmt.c6
-rw-r--r--src/bootchart/bootchart.c4
-rw-r--r--src/bus-proxyd/bus-policy.c14
-rw-r--r--src/bus-proxyd/bus-proxyd.c92
-rw-r--r--src/cgls/cgls.c6
-rw-r--r--src/cgroups-agent/cgroups-agent.c4
-rw-r--r--src/cgtop/cgtop.c4
-rw-r--r--src/console/consoled-session.c2
-rw-r--r--src/console/consoled-terminal.c8
-rw-r--r--src/console/consoled.c4
-rw-r--r--src/core/busname.c2
-rw-r--r--src/core/cgroup.c16
-rw-r--r--src/core/dbus-job.c4
-rw-r--r--src/core/dbus-manager.c6
-rw-r--r--src/core/dbus-unit.c4
-rw-r--r--src/core/dbus.c70
-rw-r--r--src/core/device.c10
-rw-r--r--src/core/execute.c6
-rw-r--r--src/core/hostname-setup.c2
-rw-r--r--src/core/job.c2
-rw-r--r--src/core/load-dropin.c4
-rw-r--r--src/core/locale-setup.c4
-rw-r--r--src/core/machine-id-setup.c4
-rw-r--r--src/core/main.c52
-rw-r--r--src/core/manager.c12
-rw-r--r--src/core/mount.c2
-rw-r--r--src/core/path.c2
-rw-r--r--src/core/scope.c2
-rw-r--r--src/core/shutdown.c12
-rw-r--r--src/core/socket.c2
-rw-r--r--src/core/swap.c2
-rw-r--r--src/core/timer.c2
-rw-r--r--src/core/transaction.c2
-rw-r--r--src/cryptsetup/cryptsetup-generator.c4
-rw-r--r--src/cryptsetup/cryptsetup.c18
-rw-r--r--src/dbus1-generator/dbus1-generator.c6
-rw-r--r--src/debug-generator/debug-generator.c2
-rw-r--r--src/delta/delta.c2
-rw-r--r--src/detect-virt/detect-virt.c6
-rw-r--r--src/efi-boot-generator/efi-boot-generator.c2
-rw-r--r--src/firstboot/firstboot.c34
-rw-r--r--src/fsck/fsck.c8
-rw-r--r--src/fstab-generator/fstab-generator.c4
-rw-r--r--src/gpt-auto-generator/gpt-auto-generator.c10
-rw-r--r--src/hibernate-resume/hibernate-resume-generator.c2
-rw-r--r--src/hibernate-resume/hibernate-resume.c2
-rw-r--r--src/hostname/hostnamectl.c2
-rw-r--r--src/hostname/hostnamed.c22
-rw-r--r--src/initctl/initctl.c6
-rw-r--r--src/journal-remote/journal-gatewayd.c22
-rw-r--r--src/journal-remote/journal-remote-write.c2
-rw-r--r--src/journal-remote/journal-remote.c26
-rw-r--r--src/journal-remote/journal-upload-journal.c16
-rw-r--r--src/journal-remote/journal-upload.c12
-rw-r--r--src/journal-remote/microhttpd-util.c4
-rw-r--r--src/journal/cat.c4
-rw-r--r--src/journal/catalog.c6
-rw-r--r--src/journal/coredump.c12
-rw-r--r--src/journal/coredumpctl.c24
-rw-r--r--src/journal/journalctl.c66
-rw-r--r--src/journal/journald-audit.c8
-rw-r--r--src/journal/journald-kmsg.c4
-rw-r--r--src/journal/journald-native.c4
-rw-r--r--src/journal/journald-server.c42
-rw-r--r--src/journal/journald-stream.c8
-rw-r--r--src/journal/journald-syslog.c2
-rw-r--r--src/journal/journald-wall.c2
-rw-r--r--src/journal/journald.c2
-rw-r--r--src/journal/sd-journal.c12
-rw-r--r--src/journal/test-compress.c4
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c4
-rw-r--r--src/libsystemd-network/sd-pppoe.c8
-rw-r--r--src/libsystemd-terminal/evcat.c14
-rw-r--r--src/libsystemd-terminal/idev-keyboard.c8
-rw-r--r--src/libsystemd-terminal/modeset.c10
-rw-r--r--src/libsystemd-terminal/subterm.c38
-rw-r--r--src/libsystemd-terminal/sysview.c4
-rw-r--r--src/libsystemd/sd-bus/bus-dump.c10
-rw-r--r--src/libsystemd/sd-bus/bus-kernel.c4
-rw-r--r--src/libsystemd/sd-bus/bus-track.c2
-rw-r--r--src/libsystemd/sd-bus/bus-util.c4
-rw-r--r--src/libsystemd/sd-bus/busctl.c36
-rw-r--r--src/libsystemd/sd-bus/test-bus-chat.c66
-rw-r--r--src/libsystemd/sd-bus/test-bus-objects.c4
-rw-r--r--src/libsystemd/sd-bus/test-bus-server.c12
-rw-r--r--src/libsystemd/sd-event/sd-event.c8
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-util.c4
-rw-r--r--src/libsystemd/sd-rtnl/test-rtnl.c8
-rw-r--r--src/locale/localectl.c10
-rw-r--r--src/locale/localed.c32
-rw-r--r--src/login/inhibit.c2
-rw-r--r--src/login/loginctl.c18
-rw-r--r--src/login/logind-button.c2
-rw-r--r--src/login/logind-core.c2
-rw-r--r--src/login/logind-inhibit.c2
-rw-r--r--src/login/logind-seat.c6
-rw-r--r--src/login/logind-session.c4
-rw-r--r--src/login/logind-user.c12
-rw-r--r--src/login/logind.c70
-rw-r--r--src/login/user-sessions.c2
-rw-r--r--src/machine/machine.c4
-rw-r--r--src/machine/machinectl.c20
-rw-r--r--src/machine/machined.c24
-rw-r--r--src/modules-load/modules-load.c8
-rw-r--r--src/network/networkctl.c10
-rw-r--r--src/network/networkd-address.c20
-rw-r--r--src/network/networkd-manager.c4
-rw-r--r--src/network/networkd-netdev-veth.c2
-rw-r--r--src/network/networkd-netdev.c2
-rw-r--r--src/network/networkd-network.c2
-rw-r--r--src/network/networkd-route.c36
-rw-r--r--src/network/networkd-wait-online-manager.c4
-rw-r--r--src/network/networkd-wait-online.c4
-rw-r--r--src/network/networkd.c16
-rw-r--r--src/notify/notify.c2
-rw-r--r--src/nspawn/nspawn.c170
-rw-r--r--src/path/path.c4
-rw-r--r--src/quotacheck/quotacheck.c2
-rw-r--r--src/random-seed/random-seed.c2
-rw-r--r--src/remount-fs/remount-fs.c2
-rw-r--r--src/resolve-host/resolve-host.c4
-rw-r--r--src/resolve/resolved-bus.c20
-rw-r--r--src/resolve/resolved-dns-scope.c20
-rw-r--r--src/resolve/resolved-dns-zone.c2
-rw-r--r--src/resolve/resolved-link.c16
-rw-r--r--src/resolve/resolved-manager.c12
-rw-r--r--src/resolve/resolved.c16
-rw-r--r--src/rfkill/rfkill.c10
-rw-r--r--src/run/run.c6
-rw-r--r--src/shared/capability.c2
-rw-r--r--src/shared/generator.c4
-rw-r--r--src/shared/install.c2
-rw-r--r--src/shared/logs-show.c28
-rw-r--r--src/shared/pager.c2
-rw-r--r--src/shared/sleep-config.c2
-rw-r--r--src/shared/socket-label.c4
-rw-r--r--src/shared/socket-util.c2
-rw-r--r--src/shared/spawn-ask-password-agent.c2
-rw-r--r--src/shared/spawn-polkit-agent.c2
-rw-r--r--src/shared/util.c8
-rw-r--r--src/shutdownd/shutdownd.c8
-rw-r--r--src/socket-proxy/socket-proxyd.c32
-rw-r--r--src/sysctl/sysctl.c6
-rw-r--r--src/systemctl/systemctl.c60
-rw-r--r--src/sysusers/sysusers.c30
-rw-r--r--src/test/test-boot-timestamps.c6
-rw-r--r--src/test/test-ns.c2
-rw-r--r--src/test/test-socket-util.c2
-rw-r--r--src/test/test-watchdog.c4
-rw-r--r--src/timedate/timedatectl.c6
-rw-r--r--src/timedate/timedated.c22
-rw-r--r--src/timesync/timesyncd-manager.c18
-rw-r--r--src/timesync/timesyncd.c8
-rw-r--r--src/tmpfiles/tmpfiles.c18
-rw-r--r--src/tty-ask-password-agent/tty-ask-password-agent.c6
-rw-r--r--src/udev/net/ethtool-util.c6
-rw-r--r--src/udev/net/link-config.c4
-rw-r--r--src/udev/udev-builtin-keyboard.c2
-rw-r--r--src/udev/udev-builtin-net_setup_link.c4
-rw-r--r--src/udev/udev-builtin-uaccess.c4
-rw-r--r--src/udev/udev-ctrl.c2
-rw-r--r--src/udev/udev-node.c4
-rw-r--r--src/udev/udev-rules.c4
-rw-r--r--src/udev/udevadm-hwdb.c4
-rw-r--r--src/udev/udevd.c6
-rw-r--r--src/update-done/update-done.c2
-rw-r--r--src/update-utmp/update-utmp.c10
-rw-r--r--src/vconsole/vconsole-setup.c12
173 files changed, 1001 insertions, 1001 deletions
diff --git a/src/ac-power/ac-power.c b/src/ac-power/ac-power.c
index bd1b6ecc72..8f35bd8bb8 100644
--- a/src/ac-power/ac-power.c
+++ b/src/ac-power/ac-power.c
@@ -29,7 +29,7 @@ int main(int argc, char *argv[]) {
r = on_ac_power();
if (r < 0) {
- log_error("Failed to read AC status: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read AC status: %m");
return EXIT_FAILURE;
}
diff --git a/src/activate/activate.c b/src/activate/activate.c
index 0a1df37f35..f4f41ed36c 100644
--- a/src/activate/activate.c
+++ b/src/activate/activate.c
@@ -103,7 +103,7 @@ static int open_sockets(int *epoll_fd, bool accept) {
fd = make_socket_fd(LOG_DEBUG, *address, SOCK_STREAM | (arg_accept*SOCK_CLOEXEC));
if (fd < 0) {
log_open();
- log_error("Failed to open '%s': %s", *address, strerror(-fd));
+ log_error_errno(-fd, "Failed to open '%s': %m", *address);
return fd;
}
diff --git a/src/analyze/analyze-verify.c b/src/analyze/analyze-verify.c
index f084579f1a..a0f33cbcc2 100644
--- a/src/analyze/analyze-verify.c
+++ b/src/analyze/analyze-verify.c
@@ -222,7 +222,7 @@ int verify_units(char **filenames, SystemdRunningAs running_as, bool check_man)
/* set the path */
r = generate_path(&var, filenames);
if (r < 0) {
- log_error("Failed to generate unit load path: %s", strerror(-r));
+ log_error_errno(-r, "Failed to generate unit load path: %m");
return r;
}
@@ -230,7 +230,7 @@ int verify_units(char **filenames, SystemdRunningAs running_as, bool check_man)
r = manager_new(running_as, true, &m);
if (r < 0) {
- log_error("Failed to initalize manager: %s", strerror(-r));
+ log_error_errno(-r, "Failed to initalize manager: %m");
return r;
}
@@ -238,7 +238,7 @@ int verify_units(char **filenames, SystemdRunningAs running_as, bool check_man)
r = manager_startup(m, serial, fdset);
if (r < 0) {
- log_error("Failed to start manager: %s", strerror(-r));
+ log_error_errno(-r, "Failed to start manager: %m");
goto finish;
}
@@ -260,7 +260,7 @@ int verify_units(char **filenames, SystemdRunningAs running_as, bool check_man)
} else
k = manager_load_unit(m, NULL, *filename, &err, &units[count]);
if (k < 0) {
- log_error("Failed to load %s: %s", *filename, strerror(-k));
+ log_error_errno(-k, "Failed to load %s: %m", *filename);
if (r == 0)
r = k;
} else
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index 5e55988063..cc6cbab65e 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -1362,7 +1362,7 @@ int main(int argc, char *argv[]) {
r = bus_open_transport_systemd(arg_transport, arg_host, arg_user, &bus);
if (r < 0) {
- log_error("Failed to create bus connection: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create bus connection: %m");
goto finish;
}
diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c
index 0a2bac6f16..ab05a7d1a7 100644
--- a/src/backlight/backlight.c
+++ b/src/backlight/backlight.c
@@ -211,7 +211,7 @@ static unsigned get_max_brightness(struct udev_device *device) {
r = safe_atou(max_brightness_str, &max_brightness);
if (r < 0) {
- log_warning("Failed to parse 'max_brightness' \"%s\": %s", max_brightness_str, strerror(-r));
+ log_warning_errno(-r, "Failed to parse 'max_brightness' \"%s\": %m", max_brightness_str);
return 0;
}
@@ -235,7 +235,7 @@ static void clamp_brightness(struct udev_device *device, char **value, unsigned
r = safe_atou(*value, &brightness);
if (r < 0) {
- log_warning("Failed to parse brightness \"%s\": %s", *value, strerror(-r));
+ log_warning_errno(-r, "Failed to parse brightness \"%s\": %m", *value);
return;
}
@@ -387,7 +387,7 @@ int main(int argc, char *argv[]) {
if (r == -ENOENT)
return EXIT_SUCCESS;
- log_error("Failed to read %s: %s", saved, strerror(-r));
+ log_error_errno(-r, "Failed to read %s: %m", saved);
return EXIT_FAILURE;
}
@@ -416,7 +416,7 @@ int main(int argc, char *argv[]) {
r = write_string_file(saved, value);
if (r < 0) {
- log_error("Failed to write %s: %s", saved, strerror(-r));
+ log_error_errno(-r, "Failed to write %s: %m", saved);
return EXIT_FAILURE;
}
diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c
index 0a15fafc60..ca650fb009 100644
--- a/src/binfmt/binfmt.c
+++ b/src/binfmt/binfmt.c
@@ -65,7 +65,7 @@ static int apply_rule(const char *rule) {
r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule);
if (r < 0) {
- log_error("Failed to add binary format: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add binary format: %m");
return r;
}
@@ -83,7 +83,7 @@ static int apply_file(const char *path, bool ignore_enoent) {
if (ignore_enoent && r == -ENOENT)
return 0;
- log_error("Failed to open file '%s', ignoring: %s", path, strerror(-r));
+ log_error_errno(-r, "Failed to open file '%s', ignoring: %m", path);
return r;
}
@@ -191,7 +191,7 @@ int main(int argc, char *argv[]) {
r = conf_files_list_nulstr(&files, ".conf", NULL, conf_file_dirs);
if (r < 0) {
- log_error("Failed to enumerate binfmt.d files: %s", strerror(-r));
+ log_error_errno(-r, "Failed to enumerate binfmt.d files: %m");
goto finish;
}
diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c
index 813e38deeb..e0a5542fa9 100644
--- a/src/bootchart/bootchart.c
+++ b/src/bootchart/bootchart.c
@@ -290,7 +290,7 @@ static void do_journal_append(char *file) {
}
n = loop_read(f, p + 10, BOOTCHART_MAX, false);
if (n < 0) {
- log_error("Failed to read bootchart data: %s", strerror(-n));
+ log_error_errno(-n, "Failed to read bootchart data: %m");
close(f);
return;
}
@@ -302,7 +302,7 @@ static void do_journal_append(char *file) {
r = sd_journal_sendv(iovec, j);
if (r < 0)
- log_error("Failed to send bootchart: %s", strerror(-r));
+ log_error_errno(-r, "Failed to send bootchart: %m");
}
int main(int argc, char *argv[]) {
diff --git a/src/bus-proxyd/bus-policy.c b/src/bus-proxyd/bus-policy.c
index 3cfe9befb2..9a83efe845 100644
--- a/src/bus-proxyd/bus-policy.c
+++ b/src/bus-proxyd/bus-policy.c
@@ -95,7 +95,7 @@ static int file_load(Policy *p, const char *path) {
if (r == -EISDIR)
return r;
- log_error("Failed to load %s: %s", path, strerror(-r));
+ log_error_errno(-r, "Failed to load %s: %m", path);
return r;
}
@@ -106,7 +106,7 @@ static int file_load(Policy *p, const char *path) {
t = xml_tokenize(&q, &name, &xml_state, &line);
if (t < 0) {
- log_error("XML parse failure in %s: %s", path, strerror(-t));
+ log_error_errno(-t, "XML parse failure in %s: %m", path);
return t;
}
@@ -358,7 +358,7 @@ static int file_load(Policy *p, const char *path) {
r = get_user_creds(&u, &i->uid, NULL, NULL, NULL);
if (r < 0) {
- log_error("Failed to resolve user %s, ignoring policy: %s", u, strerror(-r));
+ log_error_errno(-r, "Failed to resolve user %s, ignoring policy: %m", u);
free(i);
} else {
PolicyItem *first;
@@ -390,7 +390,7 @@ static int file_load(Policy *p, const char *path) {
r = get_group_creds(&g, &i->gid);
if (r < 0) {
- log_error("Failed to resolve group %s, ignoring policy: %s", g, strerror(-r));
+ log_error_errno(-r, "Failed to resolve group %s, ignoring policy: %m", g);
free(i);
} else {
PolicyItem *first;
@@ -533,7 +533,7 @@ static int file_load(Policy *p, const char *path) {
r = get_user_creds(&u, &i->uid, NULL, NULL, NULL);
if (r < 0)
- log_error("Failed to resolve user %s: %s", name, strerror(-r));
+ log_error_errno(-r, "Failed to resolve user %s: %m", name);
else
i->uid_valid = true;
}
@@ -544,7 +544,7 @@ static int file_load(Policy *p, const char *path) {
r = get_group_creds(&g, &i->gid);
if (r < 0)
- log_error("Failed to resolve group %s: %s", name, strerror(-r));
+ log_error_errno(-r, "Failed to resolve group %s: %m", name);
else
i->gid_valid = true;
}
@@ -895,7 +895,7 @@ int policy_load(Policy *p, char **files) {
r = conf_files_list(&l, ".conf", NULL, *i, NULL);
if (r < 0) {
- log_error("Failed to get configuration file list: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get configuration file list: %m");
return r;
}
diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c
index 50ffd0ac16..79f2f6e53c 100644
--- a/src/bus-proxyd/bus-proxyd.c
+++ b/src/bus-proxyd/bus-proxyd.c
@@ -1160,31 +1160,31 @@ static int process_hello(sd_bus *a, sd_bus *b, sd_bus_message *m, bool *got_hell
r = sd_bus_message_new_method_return(m, &n);
if (r < 0) {
- log_error("Failed to generate HELLO reply: %s", strerror(-r));
+ log_error_errno(-r, "Failed to generate HELLO reply: %m");
return r;
}
r = sd_bus_message_append(n, "s", a->unique_name);
if (r < 0) {
- log_error("Failed to append unique name to HELLO reply: %s", strerror(-r));
+ log_error_errno(-r, "Failed to append unique name to HELLO reply: %m");
return r;
}
r = bus_message_append_sender(n, "org.freedesktop.DBus");
if (r < 0) {
- log_error("Failed to append sender to HELLO reply: %s", strerror(-r));
+ log_error_errno(-r, "Failed to append sender to HELLO reply: %m");
return r;
}
r = bus_seal_synthetic_message(b, n);
if (r < 0) {
- log_error("Failed to seal HELLO reply: %s", strerror(-r));
+ log_error_errno(-r, "Failed to seal HELLO reply: %m");
return r;
}
r = sd_bus_send(b, n, NULL);
if (r < 0) {
- log_error("Failed to send HELLO reply: %s", strerror(-r));
+ log_error_errno(-r, "Failed to send HELLO reply: %m");
return r;
}
@@ -1196,31 +1196,31 @@ static int process_hello(sd_bus *a, sd_bus *b, sd_bus_message *m, bool *got_hell
"org.freedesktop.DBus",
"NameAcquired");
if (r < 0) {
- log_error("Failed to allocate initial NameAcquired message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate initial NameAcquired message: %m");
return r;
}
r = sd_bus_message_append(n, "s", a->unique_name);
if (r < 0) {
- log_error("Failed to append unique name to NameAcquired message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to append unique name to NameAcquired message: %m");
return r;
}
r = bus_message_append_sender(n, "org.freedesktop.DBus");
if (r < 0) {
- log_error("Failed to append sender to NameAcquired message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to append sender to NameAcquired message: %m");
return r;
}
r = bus_seal_synthetic_message(b, n);
if (r < 0) {
- log_error("Failed to seal NameAcquired message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to seal NameAcquired message: %m");
return r;
}
r = sd_bus_send(b, n, NULL);
if (r < 0) {
- log_error("Failed to send NameAcquired message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to send NameAcquired message: %m");
return r;
}
@@ -1305,7 +1305,7 @@ int main(int argc, char *argv[]) {
r = get_user_creds(&user, &uid, &gid, NULL, NULL);
if (r < 0) {
- log_error("Cannot resolve user name %s: %s", user, strerror(-r));
+ log_error_errno(-r, "Cannot resolve user name %s: %m", user);
goto finish;
}
@@ -1322,31 +1322,31 @@ int main(int argc, char *argv[]) {
r = sd_bus_new(&a);
if (r < 0) {
- log_error("Failed to allocate bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate bus: %m");
goto finish;
}
r = sd_bus_set_description(a, "sd-proxy");
if (r < 0) {
- log_error("Failed to set bus name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set bus name: %m");
goto finish;
}
r = sd_bus_set_address(a, arg_address);
if (r < 0) {
- log_error("Failed to set address to connect to: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set address to connect to: %m");
goto finish;
}
r = sd_bus_negotiate_fds(a, is_unix);
if (r < 0) {
- log_error("Failed to set FD negotiation: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set FD negotiation: %m");
goto finish;
}
r = sd_bus_negotiate_creds(a, true, SD_BUS_CREDS_UID|SD_BUS_CREDS_PID|SD_BUS_CREDS_GID|SD_BUS_CREDS_SELINUX_CONTEXT);
if (r < 0) {
- log_error("Failed to set credential negotiation: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set credential negotiation: %m");
goto finish;
}
@@ -1374,13 +1374,13 @@ int main(int argc, char *argv[]) {
r = sd_bus_start(a);
if (r < 0) {
- log_error("Failed to start bus client: %s", strerror(-r));
+ log_error_errno(-r, "Failed to start bus client: %m");
goto finish;
}
r = sd_bus_get_owner_id(a, &server_id);
if (r < 0) {
- log_error("Failed to get server ID: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get server ID: %m");
goto finish;
}
@@ -1390,13 +1390,13 @@ int main(int argc, char *argv[]) {
r = sd_bus_get_owner_creds(a, SD_BUS_CREDS_UID, &bus_creds);
if (r < 0) {
- log_error("Failed to get bus creds: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get bus creds: %m");
goto finish;
}
r = sd_bus_creds_get_uid(bus_creds, &bus_uid);
if (r < 0) {
- log_error("Failed to get bus owner UID: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get bus owner UID: %m");
goto finish;
}
@@ -1406,7 +1406,7 @@ int main(int argc, char *argv[]) {
r = policy_load(&policy_buffer, arg_configuration);
if (r < 0) {
- log_error("Failed to load policy: %s", strerror(-r));
+ log_error_errno(-r, "Failed to load policy: %m");
goto finish;
}
@@ -1423,37 +1423,37 @@ int main(int argc, char *argv[]) {
r = sd_bus_new(&b);
if (r < 0) {
- log_error("Failed to allocate bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate bus: %m");
goto finish;
}
r = sd_bus_set_fd(b, in_fd, out_fd);
if (r < 0) {
- log_error("Failed to set fds: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set fds: %m");
goto finish;
}
r = sd_bus_set_server(b, 1, server_id);
if (r < 0) {
- log_error("Failed to set server mode: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set server mode: %m");
goto finish;
}
r = sd_bus_negotiate_fds(b, is_unix);
if (r < 0) {
- log_error("Failed to set FD negotiation: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set FD negotiation: %m");
goto finish;
}
r = sd_bus_negotiate_creds(b, true, SD_BUS_CREDS_UID|SD_BUS_CREDS_PID|SD_BUS_CREDS_GID|SD_BUS_CREDS_SELINUX_CONTEXT);
if (r < 0) {
- log_error("Failed to set credential negotiation: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set credential negotiation: %m");
goto finish;
}
r = sd_bus_set_anonymous(b, true);
if (r < 0) {
- log_error("Failed to set anonymous authentication: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set anonymous authentication: %m");
goto finish;
}
@@ -1461,13 +1461,13 @@ int main(int argc, char *argv[]) {
r = sd_bus_start(b);
if (r < 0) {
- log_error("Failed to start bus client: %s", strerror(-r));
+ log_error_errno(-r, "Failed to start bus client: %m");
goto finish;
}
r = rename_service(a, b);
if (r < 0)
- log_debug("Failed to rename process: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to rename process: %m");
if (a->is_kernel) {
_cleanup_free_ char *match = NULL;
@@ -1475,7 +1475,7 @@ int main(int argc, char *argv[]) {
r = sd_bus_get_unique_name(a, &unique);
if (r < 0) {
- log_error("Failed to get unique name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get unique name: %m");
goto finish;
}
@@ -1495,7 +1495,7 @@ int main(int argc, char *argv[]) {
r = sd_bus_add_match(a, NULL, match, NULL, NULL);
if (r < 0) {
- log_error("Failed to add match for NameLost: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match for NameLost: %m");
goto finish;
}
@@ -1516,7 +1516,7 @@ int main(int argc, char *argv[]) {
r = sd_bus_add_match(a, NULL, match, NULL, NULL);
if (r < 0) {
- log_error("Failed to add match for NameAcquired: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match for NameAcquired: %m");
goto finish;
}
}
@@ -1538,7 +1538,7 @@ int main(int argc, char *argv[]) {
if (r == -ECONNRESET)
r = 0;
else
- log_error("Failed to process bus a: %s", strerror(-r));
+ log_error_errno(-r, "Failed to process bus a: %m");
goto finish;
}
@@ -1555,7 +1555,7 @@ int main(int argc, char *argv[]) {
k = synthesize_name_acquired(a, b, m);
if (k < 0) {
r = k;
- log_error("Failed to synthesize message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to synthesize message: %m");
goto finish;
}
@@ -1565,7 +1565,7 @@ int main(int argc, char *argv[]) {
k = process_policy(a, b, m, policy, &ucred, owned_names);
if (k < 0) {
r = k;
- log_error("Failed to process policy: %s", strerror(-r));
+ log_error_errno(-r, "Failed to process policy: %m");
goto finish;
} else if (k > 0) {
r = 1;
@@ -1580,7 +1580,7 @@ int main(int argc, char *argv[]) {
r = 0;
else {
r = k;
- log_error("Failed to send message to client: %s", strerror(-r));
+ log_error_errno(-r, "Failed to send message to client: %m");
}
goto finish;
@@ -1600,7 +1600,7 @@ int main(int argc, char *argv[]) {
if (r == -ECONNRESET)
r = 0;
else
- log_error("Failed to process bus b: %s", strerror(-r));
+ log_error_errno(-r, "Failed to process bus b: %m");
goto finish;
}
@@ -1617,7 +1617,7 @@ int main(int argc, char *argv[]) {
k = process_hello(a, b, m, &got_hello);
if (k < 0) {
r = k;
- log_error("Failed to process HELLO: %s", strerror(-r));
+ log_error_errno(-r, "Failed to process HELLO: %m");
goto finish;
} else if (k > 0) {
processed = true;
@@ -1628,7 +1628,7 @@ int main(int argc, char *argv[]) {
k = process_driver(a, b, m, policy, &ucred, owned_names);
if (k < 0) {
r = k;
- log_error("Failed to process driver calls: %s", strerror(-r));
+ log_error_errno(-r, "Failed to process driver calls: %m");
goto finish;
} else if (k > 0) {
processed = true;
@@ -1642,7 +1642,7 @@ int main(int argc, char *argv[]) {
k = process_policy(b, a, m, policy, &ucred, owned_names);
if (k < 0) {
r = k;
- log_error("Failed to process policy: %s", strerror(-r));
+ log_error_errno(-r, "Failed to process policy: %m");
goto finish;
} else if (k > 0) {
processed = true;
@@ -1660,7 +1660,7 @@ int main(int argc, char *argv[]) {
r = 0;
else {
r = k;
- log_error("Failed to send message to bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to send message to bus: %m");
}
goto finish;
@@ -1678,31 +1678,31 @@ int main(int argc, char *argv[]) {
fd = sd_bus_get_fd(a);
if (fd < 0) {
- log_error("Failed to get fd: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get fd: %m");
goto finish;
}
events_a = sd_bus_get_events(a);
if (events_a < 0) {
- log_error("Failed to get events mask: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get events mask: %m");
goto finish;
}
r = sd_bus_get_timeout(a, &timeout_a);
if (r < 0) {
- log_error("Failed to get timeout: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get timeout: %m");
goto finish;
}
events_b = sd_bus_get_events(b);
if (events_b < 0) {
- log_error("Failed to get events mask: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get events mask: %m");
goto finish;
}
r = sd_bus_get_timeout(b, &timeout_b);
if (r < 0) {
- log_error("Failed to get timeout: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get timeout: %m");
goto finish;
}
diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c
index 7070503d68..7fc346d6f5 100644
--- a/src/cgls/cgls.c
+++ b/src/cgls/cgls.c
@@ -155,7 +155,7 @@ int main(int argc, char *argv[]) {
r = bus_open_transport(BUS_TRANSPORT_LOCAL, NULL, false, &bus);
if (r < 0) {
- log_error("Failed to create bus connection: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create bus connection: %m");
goto finish;
}
@@ -206,7 +206,7 @@ int main(int argc, char *argv[]) {
m = strappenda("/run/systemd/machines/", arg_machine);
r = parse_env_file(m, NEWLINE, "SCOPE", &scope, NULL);
if (r < 0) {
- log_error("Failed to get machine path: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get machine path: %m");
goto finish;
}
@@ -257,7 +257,7 @@ int main(int argc, char *argv[]) {
}
if (r < 0) {
- log_error("Failed to list cgroup tree %s: %s", root, strerror(-r));
+ log_error_errno(-r, "Failed to list cgroup tree %s: %m", root);
retval = EXIT_FAILURE;
} else
retval = EXIT_SUCCESS;
diff --git a/src/cgroups-agent/cgroups-agent.c b/src/cgroups-agent/cgroups-agent.c
index e581fbc9b6..1b215b99ab 100644
--- a/src/cgroups-agent/cgroups-agent.c
+++ b/src/cgroups-agent/cgroups-agent.c
@@ -48,7 +48,7 @@ int main(int argc, char *argv[]) {
/* If we couldn't connect we assume this was triggered
* while systemd got restarted/transitioned from
* initrd to the system, so let's ignore this */
- log_debug("Failed to get D-Bus connection: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to get D-Bus connection: %m");
return EXIT_FAILURE;
}
@@ -58,7 +58,7 @@ int main(int argc, char *argv[]) {
"Released",
"s", argv[1]);
if (r < 0) {
- log_debug("Failed to send signal message on private connection: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to send signal message on private connection: %m");
return EXIT_FAILURE;
}
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
index 932a7ba7c6..79592aaa17 100644
--- a/src/cgtop/cgtop.c
+++ b/src/cgtop/cgtop.c
@@ -748,7 +748,7 @@ int main(int argc, char *argv[]) {
if (r == -ETIMEDOUT)
continue;
if (r < 0) {
- log_error("Couldn't read key: %s", strerror(-r));
+ log_error_errno(-r, "Couldn't read key: %m");
goto finish;
}
}
@@ -842,7 +842,7 @@ finish:
group_hashmap_free(b);
if (r < 0) {
- log_error("Exiting with failure: %s", strerror(-r));
+ log_error_errno(-r, "Exiting with failure: %m");
return EXIT_FAILURE;
}
diff --git a/src/console/consoled-session.c b/src/console/consoled-session.c
index 8bacacab35..abdb1bc481 100644
--- a/src/console/consoled-session.c
+++ b/src/console/consoled-session.c
@@ -231,7 +231,7 @@ void session_dirty(Session *s) {
r = sd_event_source_set_enabled(s->redraw_src, SD_EVENT_ONESHOT);
if (r < 0)
- log_error("Cannot enable redraw-source: %s", strerror(-r));
+ log_error_errno(-r, "Cannot enable redraw-source: %m");
}
void session_add_device(Session *s, sysview_device *device) {
diff --git a/src/console/consoled-terminal.c b/src/console/consoled-terminal.c
index d091579aa5..7d0f646c7e 100644
--- a/src/console/consoled-terminal.c
+++ b/src/console/consoled-terminal.c
@@ -52,7 +52,7 @@ static int terminal_pty_fn(Pty *pty, void *userdata, unsigned int event, const v
case PTY_DATA:
r = term_screen_feed_text(t->screen, ptr, size);
if (r < 0)
- log_error("Cannot update screen state: %s", strerror(-r));
+ log_error_errno(-r, "Cannot update screen state: %m");
workspace_dirty(t->workspace);
break;
@@ -128,12 +128,12 @@ void terminal_resize(Terminal *t) {
if (t->pty) {
r = pty_resize(t->pty, width, height);
if (r < 0)
- log_error("Cannot resize pty: %s", strerror(-r));
+ log_error_errno(-r, "Cannot resize pty: %m");
}
r = term_screen_resize(t->screen, width, height);
if (r < 0)
- log_error("Cannot resize screen: %s", strerror(-r));
+ log_error_errno(-r, "Cannot resize screen: %m");
}
void terminal_run(Terminal *t) {
@@ -151,7 +151,7 @@ void terminal_run(Terminal *t) {
term_screen_get_width(t->screen),
term_screen_get_height(t->screen));
if (pid < 0) {
- log_error("Cannot fork PTY: %s", strerror(-pid));
+ log_error_errno(-pid, "Cannot fork PTY: %m");
return;
} else if (pid == 0) {
/* child */
diff --git a/src/console/consoled.c b/src/console/consoled.c
index b0c9eda1ac..f76a357c97 100644
--- a/src/console/consoled.c
+++ b/src/console/consoled.c
@@ -45,7 +45,7 @@ int main(int argc, char *argv[]) {
r = manager_new(&m);
if (r < 0) {
- log_error("Could not create manager: %s", strerror(-r));
+ log_error_errno(-r, "Could not create manager: %m");
goto out;
}
@@ -55,7 +55,7 @@ int main(int argc, char *argv[]) {
r = manager_run(m);
if (r < 0) {
- log_error("Cannot run manager: %s", strerror(-r));
+ log_error_errno(-r, "Cannot run manager: %m");
goto out;
}
diff --git a/src/core/busname.c b/src/core/busname.c
index 2ad6c6e137..eaf5b3c2ba 100644
--- a/src/core/busname.c
+++ b/src/core/busname.c
@@ -409,7 +409,7 @@ static int busname_make_starter(BusName *n, pid_t *_pid) {
fail_child:
log_open();
- log_error("Failed to create starter connection at step %s: %s", exit_status_to_string(ret, EXIT_STATUS_SYSTEMD), strerror(-r));
+ log_error_errno(-r, "Failed to create starter connection at step %s: %m", exit_status_to_string(ret, EXIT_STATUS_SYSTEMD));
_exit(ret);
}
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 0951a09964..784a945dd6 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -631,7 +631,7 @@ static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) {
/* First, create our own group */
r = cg_create_everywhere(u->manager->cgroup_supported, mask, u->cgroup_path);
if (r < 0) {
- log_error("Failed to create cgroup %s: %s", u->cgroup_path, strerror(-r));
+ log_error_errno(-r, "Failed to create cgroup %s: %m", u->cgroup_path);
return r;
}
@@ -642,7 +642,7 @@ static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) {
/* Then, possibly move things over */
r = cg_migrate_everywhere(u->manager->cgroup_supported, u->cgroup_path, u->cgroup_path, migrate_callback, u);
if (r < 0)
- log_warning("Failed to migrate cgroup from to %s: %s", u->cgroup_path, strerror(-r));
+ log_warning_errno(-r, "Failed to migrate cgroup from to %s: %m", u->cgroup_path);
return 0;
}
@@ -715,7 +715,7 @@ unsigned manager_dispatch_cgroup_queue(Manager *m) {
r = unit_realize_cgroup_now(i, state);
if (r < 0)
- log_warning("Failed to realize cgroups for queued unit %s: %s", i->id, strerror(-r));
+ log_warning_errno(-r, "Failed to realize cgroups for queued unit %s: %m", i->id);
n++;
}
@@ -798,7 +798,7 @@ void unit_destroy_cgroup(Unit *u) {
r = cg_trim_everywhere(u->manager->cgroup_supported, u->cgroup_path, !unit_has_name(u, SPECIAL_ROOT_SLICE));
if (r < 0)
- log_debug("Failed to destroy cgroup %s: %s", u->cgroup_path, strerror(-r));
+ log_debug_errno(-r, "Failed to destroy cgroup %s: %m", u->cgroup_path);
hashmap_remove(u->manager->cgroup_unit, u->cgroup_path);
@@ -858,7 +858,7 @@ int manager_setup_cgroup(Manager *m) {
r = cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, 0, &m->cgroup_root);
if (r < 0) {
- log_error("Cannot determine cgroup we are running in: %s", strerror(-r));
+ log_error_errno(-r, "Cannot determine cgroup we are running in: %m");
return r;
}
@@ -884,7 +884,7 @@ int manager_setup_cgroup(Manager *m) {
/* 2. Show data */
r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, NULL, &path);
if (r < 0) {
- log_error("Cannot find cgroup mount point: %s", strerror(-r));
+ log_error_errno(-r, "Cannot find cgroup mount point: %m");
return r;
}
@@ -895,7 +895,7 @@ int manager_setup_cgroup(Manager *m) {
if (m->running_as == SYSTEMD_SYSTEM) {
r = cg_install_release_agent(SYSTEMD_CGROUP_CONTROLLER, SYSTEMD_CGROUP_AGENT_PATH);
if (r < 0)
- log_warning("Failed to install release agent, ignoring: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to install release agent, ignoring: %m");
else if (r > 0)
log_debug("Installed release agent.");
else
@@ -905,7 +905,7 @@ int manager_setup_cgroup(Manager *m) {
/* 4. Make sure we are in the root cgroup */
r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, 0);
if (r < 0) {
- log_error("Failed to create root cgroup hierarchy: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create root cgroup hierarchy: %m");
return r;
}
diff --git a/src/core/dbus-job.c b/src/core/dbus-job.c
index 09f5739315..36d6dee75f 100644
--- a/src/core/dbus-job.c
+++ b/src/core/dbus-job.c
@@ -154,7 +154,7 @@ void bus_job_send_change_signal(Job *j) {
r = bus_foreach_bus(j->manager, j->clients, j->sent_dbus_new_signal ? send_changed_signal : send_new_signal, j);
if (r < 0)
- log_debug("Failed to send job change signal for %u: %s", j->id, strerror(-r));
+ log_debug_errno(-r, "Failed to send job change signal for %u: %m", j->id);
j->sent_dbus_new_signal = true;
}
@@ -198,5 +198,5 @@ void bus_job_send_removed_signal(Job *j) {
r = bus_foreach_bus(j->manager, j->clients, send_removed_signal, j);
if (r < 0)
- log_debug("Failed to send job remove signal for %u: %s", j->id, strerror(-r));
+ log_debug_errno(-r, "Failed to send job remove signal for %u: %m", j->id);
}
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 1384e8faba..765d376820 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -1514,7 +1514,7 @@ static int reply_unit_file_changes_and_free(
if (n_changes > 0) {
r = bus_foreach_bus(m, NULL, send_unit_files_changed, NULL);
if (r < 0)
- log_debug("Failed to send UnitFilesChanged signal: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to send UnitFilesChanged signal: %m");
}
r = sd_bus_message_new_method_return(message, &reply);
@@ -1998,7 +1998,7 @@ void bus_manager_send_finished(
total_usec
});
if (r < 0)
- log_debug("Failed to send finished signal: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to send finished signal: %m");
}
static int send_reloading(sd_bus *bus, void *userdata) {
@@ -2025,6 +2025,6 @@ void bus_manager_send_reloading(Manager *m, bool active) {
r = bus_foreach_bus(m, NULL, send_reloading, INT_TO_PTR(active));
if (r < 0)
- log_debug("Failed to send reloading signal: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to send reloading signal: %m");
}
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index 5dcde25a2d..9635fcd543 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -693,7 +693,7 @@ void bus_unit_send_change_signal(Unit *u) {
r = bus_foreach_bus(u->manager, NULL, u->sent_dbus_new_signal ? send_changed_signal : send_new_signal, u);
if (r < 0)
- log_debug("Failed to send unit change signal for %s: %s", u->id, strerror(-r));
+ log_debug_errno(-r, "Failed to send unit change signal for %s: %m", u->id);
u->sent_dbus_new_signal = true;
}
@@ -739,7 +739,7 @@ void bus_unit_send_removed_signal(Unit *u) {
r = bus_foreach_bus(u->manager, NULL, send_removed_signal, u);
if (r < 0)
- log_debug("Failed to send unit remove signal for %s: %s", u->id, strerror(-r));
+ log_debug_errno(-r, "Failed to send unit remove signal for %s: %m", u->id);
}
int bus_unit_queue_job(
diff --git a/src/core/dbus.c b/src/core/dbus.c
index e23d36fddc..b02cf34e5d 100644
--- a/src/core/dbus.c
+++ b/src/core/dbus.c
@@ -64,7 +64,7 @@ int bus_send_queued_message(Manager *m) {
r = sd_bus_send(m->queued_message_bus, m->queued_message, NULL);
if (r < 0)
- log_warning("Failed to send queued message: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to send queued message: %m");
m->queued_message = sd_bus_message_unref(m->queued_message);
m->queued_message_bus = sd_bus_unref(m->queued_message_bus);
@@ -95,7 +95,7 @@ static int signal_agent_released(sd_bus *bus, sd_bus_message *message, void *use
r = sd_bus_send(m->system_bus, message, NULL);
if (r < 0)
- log_warning("Failed to forward Released message: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to forward Released message: %m");
}
return 0;
@@ -203,7 +203,7 @@ failed:
r = sd_bus_send_to(bus, reply, "org.freedesktop.DBus", NULL);
if (r < 0) {
- log_error("Failed to respond with to bus activation request: %s", strerror(-r));
+ log_error_errno(-r, "Failed to respond with to bus activation request: %m");
return r;
}
@@ -538,58 +538,58 @@ static int bus_setup_api_vtables(Manager *m, sd_bus *bus) {
#ifdef HAVE_SELINUX
r = sd_bus_add_filter(bus, NULL, mac_selinux_filter, m);
if (r < 0) {
- log_error("Failed to add SELinux access filter: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add SELinux access filter: %m");
return r;
}
#endif
r = sd_bus_add_object_vtable(bus, NULL, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", bus_manager_vtable, m);
if (r < 0) {
- log_error("Failed to register Manager vtable: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register Manager vtable: %m");
return r;
}
r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/job", "org.freedesktop.systemd1.Job", bus_job_vtable, bus_job_find, m);
if (r < 0) {
- log_error("Failed to register Job vtable: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register Job vtable: %m");
return r;
}
r = sd_bus_add_node_enumerator(bus, NULL, "/org/freedesktop/systemd1/job", bus_job_enumerate, m);
if (r < 0) {
- log_error("Failed to add job enumerator: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add job enumerator: %m");
return r;
}
r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", "org.freedesktop.systemd1.Unit", bus_unit_vtable, bus_unit_find, m);
if (r < 0) {
- log_error("Failed to register Unit vtable: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register Unit vtable: %m");
return r;
}
r = sd_bus_add_node_enumerator(bus, NULL, "/org/freedesktop/systemd1/unit", bus_unit_enumerate, m);
if (r < 0) {
- log_error("Failed to add job enumerator: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add job enumerator: %m");
return r;
}
for (t = 0; t < _UNIT_TYPE_MAX; t++) {
r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, unit_vtable[t]->bus_vtable, bus_unit_interface_find, m);
if (r < 0) {
- log_error("Failed to register type specific vtable for %s: %s", unit_vtable[t]->bus_interface, strerror(-r));
+ log_error_errno(-r, "Failed to register type specific vtable for %s: %m", unit_vtable[t]->bus_interface);
return r;
}
if (unit_vtable[t]->cgroup_context_offset > 0) {
r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, bus_unit_cgroup_vtable, bus_unit_cgroup_find, m);
if (r < 0) {
- log_error("Failed to register control group unit vtable for %s: %s", unit_vtable[t]->bus_interface, strerror(-r));
+ log_error_errno(-r, "Failed to register control group unit vtable for %s: %m", unit_vtable[t]->bus_interface);
return r;
}
r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, bus_cgroup_vtable, bus_cgroup_context_find, m);
if (r < 0) {
- log_error("Failed to register control group vtable for %s: %s", unit_vtable[t]->bus_interface, strerror(-r));
+ log_error_errno(-r, "Failed to register control group vtable for %s: %m", unit_vtable[t]->bus_interface);
return r;
}
}
@@ -597,7 +597,7 @@ static int bus_setup_api_vtables(Manager *m, sd_bus *bus) {
if (unit_vtable[t]->exec_context_offset > 0) {
r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, bus_exec_vtable, bus_exec_context_find, m);
if (r < 0) {
- log_error("Failed to register execute vtable for %s: %s", unit_vtable[t]->bus_interface, strerror(-r));
+ log_error_errno(-r, "Failed to register execute vtable for %s: %m", unit_vtable[t]->bus_interface);
return r;
}
}
@@ -605,7 +605,7 @@ static int bus_setup_api_vtables(Manager *m, sd_bus *bus) {
if (unit_vtable[t]->kill_context_offset > 0) {
r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, bus_kill_vtable, bus_kill_context_find, m);
if (r < 0) {
- log_error("Failed to register kill vtable for %s: %s", unit_vtable[t]->bus_interface, strerror(-r));
+ log_error_errno(-r, "Failed to register kill vtable for %s: %m", unit_vtable[t]->bus_interface);
return r;
}
}
@@ -631,7 +631,7 @@ static int bus_setup_disconnected_match(Manager *m, sd_bus *bus) {
signal_disconnected, m);
if (r < 0) {
- log_error("Failed to register match for Disconnected message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register match for Disconnected message: %m");
return r;
}
@@ -667,13 +667,13 @@ static int bus_on_connection(sd_event_source *s, int fd, uint32_t revents, void
r = sd_bus_new(&bus);
if (r < 0) {
- log_warning("Failed to allocate new private connection bus: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to allocate new private connection bus: %m");
return 0;
}
r = sd_bus_set_fd(bus, nfd, nfd);
if (r < 0) {
- log_warning("Failed to set fd on new connection bus: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to set fd on new connection bus: %m");
return 0;
}
@@ -681,7 +681,7 @@ static int bus_on_connection(sd_event_source *s, int fd, uint32_t revents, void
r = bus_check_peercred(bus);
if (r < 0) {
- log_warning("Incoming private connection from unprivileged client, refusing: %s", strerror(-r));
+ log_warning_errno(-r, "Incoming private connection from unprivileged client, refusing: %m");
return 0;
}
@@ -689,19 +689,19 @@ static int bus_on_connection(sd_event_source *s, int fd, uint32_t revents, void
r = sd_bus_set_server(bus, 1, id);
if (r < 0) {
- log_warning("Failed to enable server support for new connection bus: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to enable server support for new connection bus: %m");
return 0;
}
r = sd_bus_start(bus);
if (r < 0) {
- log_warning("Failed to start new connection bus: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to start new connection bus: %m");
return 0;
}
r = sd_bus_attach_event(bus, m->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0) {
- log_warning("Failed to attach new connection bus to event loop: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to attach new connection bus to event loop: %m");
return 0;
}
@@ -719,7 +719,7 @@ static int bus_on_connection(sd_event_source *s, int fd, uint32_t revents, void
signal_agent_released, m);
if (r < 0) {
- log_warning("Failed to register Released match on new connection bus: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to register Released match on new connection bus: %m");
return 0;
}
}
@@ -730,13 +730,13 @@ static int bus_on_connection(sd_event_source *s, int fd, uint32_t revents, void
r = bus_setup_api_vtables(m, bus);
if (r < 0) {
- log_warning("Failed to set up API vtables on new connection bus: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to set up API vtables on new connection bus: %m");
return 0;
}
r = set_put(m->private_buses, bus);
if (r < 0) {
- log_warning("Failed to add new conenction bus to set: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to add new conenction bus to set: %m");
return 0;
}
@@ -757,7 +757,7 @@ static int bus_list_names(Manager *m, sd_bus *bus) {
r = sd_bus_list_names(bus, &names, NULL);
if (r < 0) {
- log_error("Failed to get initial list of names: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get initial list of names: %m");
return r;
}
@@ -782,7 +782,7 @@ static int bus_setup_api(Manager *m, sd_bus *bus) {
SD_BUS_CREDS_EUID|SD_BUS_CREDS_EFFECTIVE_CAPS|
SD_BUS_CREDS_SELINUX_CONTEXT);
if (r < 0)
- log_warning("Failed to enable credential passing, ignoring: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to enable credential passing, ignoring: %m");
r = bus_setup_api_vtables(m, bus);
if (r < 0)
@@ -798,7 +798,7 @@ static int bus_setup_api(Manager *m, sd_bus *bus) {
"member='NameOwnerChanged'",
signal_name_owner_changed, m);
if (r < 0)
- log_warning("Failed to subscribe to NameOwnerChanged signal: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to subscribe to NameOwnerChanged signal: %m");
r = sd_bus_add_match(
bus,
@@ -810,7 +810,7 @@ static int bus_setup_api(Manager *m, sd_bus *bus) {
"member='ActivationRequest'",
signal_activation_request, m);
if (r < 0)
- log_warning("Failed to subscribe to activation signal: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to subscribe to activation signal: %m");
/* Allow replacing of our name, to ease implementation of
* reexecution, where we keep the old connection open until
@@ -819,7 +819,7 @@ static int bus_setup_api(Manager *m, sd_bus *bus) {
* finish */
r = sd_bus_request_name(bus,"org.freedesktop.systemd1", SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_ALLOW_REPLACEMENT);
if (r < 0) {
- log_error("Failed to register name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register name: %m");
return r;
}
@@ -852,7 +852,7 @@ static int bus_init_api(Manager *m) {
r = sd_bus_attach_event(bus, m->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0) {
- log_error("Failed to attach API bus to event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to attach API bus to event loop: %m");
return 0;
}
@@ -863,7 +863,7 @@ static int bus_init_api(Manager *m) {
r = bus_setup_api(m, bus);
if (r < 0) {
- log_error("Failed to set up API bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set up API bus: %m");
return 0;
}
@@ -894,7 +894,7 @@ static int bus_setup_system(Manager *m, sd_bus *bus) {
signal_agent_released, m);
if (r < 0)
- log_warning("Failed to register Released match on system bus: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to register Released match on system bus: %m");
log_debug("Successfully connected to system bus.");
return 0;
@@ -925,13 +925,13 @@ static int bus_init_system(Manager *m) {
r = sd_bus_attach_event(bus, m->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0) {
- log_error("Failed to attach system bus to event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to attach system bus to event loop: %m");
return 0;
}
r = bus_setup_system(m, bus);
if (r < 0) {
- log_error("Failed to set up system bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set up system bus: %m");
return 0;
}
@@ -1007,7 +1007,7 @@ static int bus_init_private(Manager *m) {
r = sd_event_add_io(m->event, &s, fd, EPOLLIN, bus_on_connection, m);
if (r < 0) {
- log_error("Failed to allocate event source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate event source: %m");
return r;
}
diff --git a/src/core/device.c b/src/core/device.c
index 068578dc82..42e3a261e2 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -334,7 +334,7 @@ static int device_update_unit(Manager *m, struct udev_device *dev, const char *p
return 0;
fail:
- log_warning("Failed to load device unit: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to load device unit: %m");
if (delete && u)
unit_free(u);
@@ -650,20 +650,20 @@ static int device_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
if (streq(action, "remove") || !device_is_ready(dev)) {
r = device_process_removed_device(m, dev);
if (r < 0)
- log_error("Failed to process device remove event: %s", strerror(-r));
+ log_error_errno(-r, "Failed to process device remove event: %m");
r = swap_process_removed_device(m, dev);
if (r < 0)
- log_error("Failed to process swap device remove event: %s", strerror(-r));
+ log_error_errno(-r, "Failed to process swap device remove event: %m");
} else {
r = device_process_new_device(m, dev);
if (r < 0)
- log_error("Failed to process device new event: %s", strerror(-r));
+ log_error_errno(-r, "Failed to process device new event: %m");
r = swap_process_new_device(m, dev);
if (r < 0)
- log_error("Failed to process swap device new event: %s", strerror(-r));
+ log_error_errno(-r, "Failed to process swap device new event: %m");
manager_dispatch_load_queue(m);
diff --git a/src/core/execute.c b/src/core/execute.c
index a48c15d817..d10f362c2e 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -823,7 +823,7 @@ static int setup_pam(
* If this fails, ignore the error - but expect sd-pam threads
* to fail to exit normally */
if (setresuid(uid, uid, uid) < 0)
- log_error("Error: Failed to setresuid() in sd-pam: %s", strerror(-r));
+ log_error_errno(-r, "Error: Failed to setresuid() in sd-pam: %m");
/* Wait until our parent died. This will only work if
* the above setresuid() succeeds, otherwise the kernel
@@ -2819,7 +2819,7 @@ void exec_runtime_destroy(ExecRuntime *rt) {
r = asynchronous_job(remove_tmpdir_thread, rt->tmp_dir);
if (r < 0) {
- log_warning("Failed to nuke %s: %s", rt->tmp_dir, strerror(-r));
+ log_warning_errno(-r, "Failed to nuke %s: %m", rt->tmp_dir);
free(rt->tmp_dir);
}
@@ -2831,7 +2831,7 @@ void exec_runtime_destroy(ExecRuntime *rt) {
r = asynchronous_job(remove_tmpdir_thread, rt->var_tmp_dir);
if (r < 0) {
- log_warning("Failed to nuke %s: %s", rt->var_tmp_dir, strerror(-r));
+ log_warning_errno(-r, "Failed to nuke %s: %m", rt->var_tmp_dir);
free(rt->var_tmp_dir);
}
diff --git a/src/core/hostname-setup.c b/src/core/hostname-setup.c
index 57baa79275..74ff64883f 100644
--- a/src/core/hostname-setup.c
+++ b/src/core/hostname-setup.c
@@ -64,7 +64,7 @@ int hostname_setup(void) {
if (r == -ENOENT)
enoent = true;
else
- log_warning("Failed to read configured hostname: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to read configured hostname: %m");
hn = NULL;
} else
diff --git a/src/core/job.c b/src/core/job.c
index 8968091bdc..ff4982ef0b 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -1097,7 +1097,7 @@ int job_coldplug(Job *j) {
j->begin_usec + j->unit->job_timeout, 0,
job_dispatch_timer, j);
if (r < 0)
- log_debug("Failed to restart timeout for job: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to restart timeout for job: %m");
return r;
}
diff --git a/src/core/load-dropin.c b/src/core/load-dropin.c
index ffc68b4d73..fcc5881090 100644
--- a/src/core/load-dropin.c
+++ b/src/core/load-dropin.c
@@ -87,7 +87,7 @@ static int iterate_dir(
r = unit_add_dependency_by_name(u, dependency, de->d_name, f, true);
if (r < 0)
- log_error("Cannot add dependency %s to %s, ignoring: %s", de->d_name, u->id, strerror(-r));
+ log_error_errno(-r, "Cannot add dependency %s to %s, ignoring: %m", de->d_name, u->id);
}
return 0;
@@ -155,7 +155,7 @@ char **unit_find_dropin_paths(Unit *u) {
r = conf_files_list_strv(&configs, ".conf", NULL, (const char**) strv);
if (r < 0) {
- log_error("Failed to get list of configuration files: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get list of configuration files: %m");
strv_free(configs);
return NULL;
}
diff --git a/src/core/locale-setup.c b/src/core/locale-setup.c
index 5177dbfd08..4264ec8751 100644
--- a/src/core/locale-setup.c
+++ b/src/core/locale-setup.c
@@ -56,7 +56,7 @@ int locale_setup(char ***environment) {
NULL);
if (r < 0 && r != -ENOENT)
- log_warning("Failed to read /proc/cmdline: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to read /proc/cmdline: %m");
}
/* Hmm, nothing set on the kernel cmd line? Then let's
@@ -80,7 +80,7 @@ int locale_setup(char ***environment) {
NULL);
if (r < 0 && r != -ENOENT)
- log_warning("Failed to read /etc/locale.conf: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to read /etc/locale.conf: %m");
}
add = NULL;
diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
index ce6d8e02d0..8fedf69802 100644
--- a/src/core/machine-id-setup.c
+++ b/src/core/machine-id-setup.c
@@ -142,7 +142,7 @@ static int generate(char id[34], const char *root) {
/* If that didn't work, generate a random machine id */
r = sd_id128_randomize(&buf);
if (r < 0) {
- log_error("Failed to open /dev/urandom: %s", strerror(-r));
+ log_error_errno(-r, "Failed to open /dev/urandom: %m");
return r;
}
@@ -242,7 +242,7 @@ int machine_id_setup(const char *root) {
r = write_string_file(run_machine_id, id);
}
if (r < 0) {
- log_error("Cannot write %s: %s", run_machine_id, strerror(-r));
+ log_error_errno(-r, "Cannot write %s: %m", run_machine_id);
unlink(run_machine_id);
return r;
}
diff --git a/src/core/main.c b/src/core/main.c
index 78054afc4d..b5230c948b 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -175,7 +175,7 @@ noreturn static void crash(int sig) {
/* Order things nicely. */
r = wait_for_terminate(pid, &status);
if (r < 0)
- log_emergency("Caught <%s>, waitpid() failed: %s", signal_to_string(sig), strerror(-r));
+ log_emergency_errno(-r, "Caught <%s>, waitpid() failed: %m", signal_to_string(sig));
else if (status.si_code != CLD_DUMPED)
log_emergency("Caught <%s>, core dump failed.", signal_to_string(sig));
else
@@ -232,7 +232,7 @@ static int console_setup(void) {
tty_fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC);
if (tty_fd < 0) {
- log_error("Failed to open /dev/console: %s", strerror(-tty_fd));
+ log_error_errno(-tty_fd, "Failed to open /dev/console: %m");
return tty_fd;
}
@@ -240,7 +240,7 @@ static int console_setup(void) {
* pictures already from initrd. */
r = reset_terminal_fd(tty_fd, false);
if (r < 0) {
- log_error("Failed to reset /dev/console: %s", strerror(-r));
+ log_error_errno(-r, "Failed to reset /dev/console: %m");
return r;
}
@@ -807,7 +807,7 @@ static int parse_argv(int argc, char *argv[]) {
r = set_default_unit(optarg);
if (r < 0) {
- log_error("Failed to set default unit %s: %s", optarg, strerror(-r));
+ log_error_errno(-r, "Failed to set default unit %s: %m", optarg);
return r;
}
@@ -990,7 +990,7 @@ static int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds, bool switching
r = manager_open_serialization(m, &f);
if (r < 0) {
- log_error("Failed to create serialization file: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create serialization file: %m");
goto fail;
}
@@ -1001,13 +1001,13 @@ static int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds, bool switching
fds = fdset_new();
if (!fds) {
r = -ENOMEM;
- log_error("Failed to allocate fd set: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate fd set: %m");
goto fail;
}
r = manager_serialize(m, f, fds, switching_root);
if (r < 0) {
- log_error("Failed to serialize state: %s", strerror(-r));
+ log_error_errno(-r, "Failed to serialize state: %m");
goto fail;
}
@@ -1018,13 +1018,13 @@ static int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds, bool switching
r = fd_cloexec(fileno(f), false);
if (r < 0) {
- log_error("Failed to disable O_CLOEXEC for serialization: %s", strerror(-r));
+ log_error_errno(-r, "Failed to disable O_CLOEXEC for serialization: %m");
goto fail;
}
r = fdset_cloexec(fds, false);
if (r < 0) {
- log_error("Failed to disable O_CLOEXEC for serialization fds: %s", strerror(-r));
+ log_error_errno(-r, "Failed to disable O_CLOEXEC for serialization fds: %m");
goto fail;
}
@@ -1071,7 +1071,7 @@ static int bump_rlimit_nofile(struct rlimit *saved_rlimit) {
nl.rlim_cur = nl.rlim_max = 64*1024;
r = setrlimit_closest(RLIMIT_NOFILE, &nl);
if (r < 0) {
- log_error("Setting RLIMIT_NOFILE failed: %s", strerror(-r));
+ log_error_errno(-r, "Setting RLIMIT_NOFILE failed: %m");
return r;
}
@@ -1154,20 +1154,20 @@ static int enforce_syscall_archs(Set *archs) {
if (r == -EEXIST)
continue;
if (r < 0) {
- log_error("Failed to add architecture to seccomp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add architecture to seccomp: %m");
goto finish;
}
}
r = seccomp_attr_set(seccomp, SCMP_FLTATR_CTL_NNP, 0);
if (r < 0) {
- log_error("Failed to unset NO_NEW_PRIVS: %s", strerror(-r));
+ log_error_errno(-r, "Failed to unset NO_NEW_PRIVS: %m");
goto finish;
}
r = seccomp_load(seccomp);
if (r < 0)
- log_error("Failed to add install architecture seccomp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add install architecture seccomp: %m");
finish:
seccomp_release(seccomp);
@@ -1193,7 +1193,7 @@ static int status_welcome(void) {
}
if (r < 0 && r != -ENOENT)
- log_warning("Failed to read os-release file: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to read os-release file: %m");
return status_printf(NULL, false, false,
"\nWelcome to \x1B[%sm%s\x1B[0m!\n",
@@ -1324,7 +1324,7 @@ int main(int argc, char *argv[]) {
*/
r = clock_set_timezone(&min);
if (r < 0)
- log_error("Failed to apply local time delta, ignoring: %s", strerror(-r));
+ log_error_errno(-r, "Failed to apply local time delta, ignoring: %m");
else
log_info("RTC configured in localtime, applying delta of %i minutes to system time.", min);
} else if (!in_initrd()) {
@@ -1383,7 +1383,7 @@ int main(int argc, char *argv[]) {
/* Initialize default unit */
r = set_default_unit(SPECIAL_DEFAULT_TARGET);
if (r < 0) {
- log_emergency("Failed to set default unit %s: %s", SPECIAL_DEFAULT_TARGET, strerror(-r));
+ log_emergency_errno(-r, "Failed to set default unit %s: %m", SPECIAL_DEFAULT_TARGET);
error_message = "Failed to set default unit";
goto finish;
}
@@ -1422,7 +1422,7 @@ int main(int argc, char *argv[]) {
if (arg_running_as == SYSTEMD_SYSTEM) {
r = parse_proc_cmdline(parse_proc_cmdline_item);
if (r < 0)
- log_warning("Failed to parse kernel command line, ignoring: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to parse kernel command line, ignoring: %m");
}
/* Note that this also parses bits from the kernel command
@@ -1488,7 +1488,7 @@ int main(int argc, char *argv[]) {
/* Remember open file descriptors for later deserialization */
r = fdset_new_fill(&fds);
if (r < 0) {
- log_emergency("Failed to allocate fd set: %s", strerror(-r));
+ log_emergency_errno(-r, "Failed to allocate fd set: %m");
error_message = "Failed to allocate fd set";
goto finish;
} else
@@ -1591,13 +1591,13 @@ int main(int argc, char *argv[]) {
if (arg_capability_bounding_set_drop) {
r = capability_bounding_set_drop_usermode(arg_capability_bounding_set_drop);
if (r < 0) {
- log_emergency("Failed to drop capability bounding set of usermode helpers: %s", strerror(-r));
+ log_emergency_errno(-r, "Failed to drop capability bounding set of usermode helpers: %m");
error_message = "Failed to drop capability bounding set of usermode helpers";
goto finish;
}
r = capability_bounding_set_drop(arg_capability_bounding_set_drop, true);
if (r < 0) {
- log_emergency("Failed to drop capability bounding set: %s", strerror(-r));
+ log_emergency_errno(-r, "Failed to drop capability bounding set: %m");
error_message = "Failed to drop capability bounding set";
goto finish;
}
@@ -1626,7 +1626,7 @@ int main(int argc, char *argv[]) {
if (empty_etc) {
r = unit_file_preset_all(UNIT_FILE_SYSTEM, false, NULL, UNIT_FILE_PRESET_FULL, false, NULL, 0);
if (r < 0)
- log_warning("Failed to populate /etc with preset unit settings, ignoring: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to populate /etc with preset unit settings, ignoring: %m");
else
log_info("Populated /etc with preset unit settings.");
}
@@ -1634,7 +1634,7 @@ int main(int argc, char *argv[]) {
r = manager_new(arg_running_as, arg_action == ACTION_TEST, &m);
if (r < 0) {
- log_emergency("Failed to allocate manager object: %s", strerror(-r));
+ log_emergency_errno(-r, "Failed to allocate manager object: %m");
error_message = "Failed to allocate manager object";
goto finish;
}
@@ -1672,7 +1672,7 @@ int main(int argc, char *argv[]) {
r = manager_startup(m, arg_serialization, fds);
if (r < 0)
- log_error("Failed to fully start up daemon: %s", strerror(-r));
+ log_error_errno(-r, "Failed to fully start up daemon: %m");
/* This will close all file descriptors that were opened, but
* not claimed by any unit. */
@@ -1759,7 +1759,7 @@ int main(int argc, char *argv[]) {
for (;;) {
r = manager_loop(m);
if (r < 0) {
- log_emergency("Failed to run main loop: %s", strerror(-r));
+ log_emergency_errno(-r, "Failed to run main loop: %m");
error_message = "Failed to run main loop";
goto finish;
}
@@ -1775,7 +1775,7 @@ int main(int argc, char *argv[]) {
log_info("Reloading.");
r = manager_reload(m);
if (r < 0)
- log_error("Failed to reload: %s", strerror(-r));
+ log_error_errno(-r, "Failed to reload: %m");
break;
case MANAGER_REEXECUTE:
@@ -1876,7 +1876,7 @@ finish:
/* And switch root with MS_MOVE, because we remove the old directory afterwards and detach it. */
r = switch_root(switch_root_dir, "/mnt", true, MS_MOVE);
if (r < 0)
- log_error("Failed to switch root, trying to continue: %s", strerror(-r));
+ log_error_errno(-r, "Failed to switch root, trying to continue: %m");
}
args_size = MAX(6, argc+1);
diff --git a/src/core/manager.c b/src/core/manager.c
index 164676126f..94e347ef20 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -303,7 +303,7 @@ static int manager_watch_idle_pipe(Manager *m) {
r = sd_event_add_io(m->event, &m->idle_pipe_event_source, m->idle_pipe[2], EPOLLIN, manager_dispatch_idle_pipe_fd, m);
if (r < 0) {
- log_error("Failed to watch idle pipe: %s", strerror(-r));
+ log_error_errno(-r, "Failed to watch idle pipe: %m");
return r;
}
@@ -349,7 +349,7 @@ static int manager_setup_time_change(Manager *m) {
r = sd_event_add_io(m->event, &m->time_change_event_source, m->time_change_fd, EPOLLIN, manager_dispatch_time_change_fd, m);
if (r < 0) {
- log_error("Failed to create time change event source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create time change event source: %m");
return r;
}
@@ -697,7 +697,7 @@ static int manager_setup_notify(Manager *m) {
if (!m->notify_event_source) {
r = sd_event_add_io(m->event, &m->notify_event_source, m->notify_fd, EPOLLIN, manager_dispatch_notify_fd, m);
if (r < 0) {
- log_error("Failed to allocate notify event source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate notify event source: %m");
return -errno;
}
@@ -705,7 +705,7 @@ static int manager_setup_notify(Manager *m) {
* still identify to which service an exit message belongs */
r = sd_event_source_set_priority(m->notify_event_source, -7);
if (r < 0) {
- log_error("Failed to set priority of notify event source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set priority of notify event source: %m");
return r;
}
}
@@ -1060,7 +1060,7 @@ static void manager_build_unit_path_cache(Manager *m) {
return;
fail:
- log_error("Failed to build unit path cache: %s", strerror(-r));
+ log_error_errno(-r, "Failed to build unit path cache: %m");
set_free_free(m->unit_path_cache);
m->unit_path_cache = NULL;
@@ -1989,7 +1989,7 @@ int manager_loop(Manager *m) {
r = sd_event_run(m->event, wait_usec);
if (r < 0) {
- log_error("Failed to run event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to run event loop: %m");
return r;
}
}
diff --git a/src/core/mount.c b/src/core/mount.c
index d34699bca8..9d4513cc18 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -1627,7 +1627,7 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
r = mount_load_proc_self_mountinfo(m, true);
if (r < 0) {
- log_error("Failed to reread /proc/self/mountinfo: %s", strerror(-r));
+ log_error_errno(-r, "Failed to reread /proc/self/mountinfo: %m");
/* Reset flags, just in case, for later calls */
LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_MOUNT]) {
diff --git a/src/core/path.c b/src/core/path.c
index d399238a41..cd7478f1fc 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -250,7 +250,7 @@ static void path_spec_mkdir(PathSpec *s, mode_t mode) {
r = mkdir_p_label(s->path, mode);
if (r < 0)
- log_warning("mkdir(%s) failed: %s", s->path, strerror(-r));
+ log_warning_errno(-r, "mkdir(%s) failed: %m", s->path);
}
static void path_spec_dump(PathSpec *s, FILE *f, const char *prefix) {
diff --git a/src/core/scope.c b/src/core/scope.c
index a2b9265061..abadd1f827 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -290,7 +290,7 @@ static int scope_start(Unit *u) {
r = unit_realize_cgroup(u);
if (r < 0) {
- log_error("Failed to realize cgroup: %s", strerror(-r));
+ log_error_errno(-r, "Failed to realize cgroup: %m");
return r;
}
diff --git a/src/core/shutdown.c b/src/core/shutdown.c
index 121998ff5c..53c701a8f0 100644
--- a/src/core/shutdown.c
+++ b/src/core/shutdown.c
@@ -240,7 +240,7 @@ int main(int argc, char *argv[]) {
} else if (r > 0)
log_info("Not all file systems unmounted, %d left.", r);
else
- log_error("Failed to unmount file systems: %s", strerror(-r));
+ log_error_errno(-r, "Failed to unmount file systems: %m");
}
if (need_swapoff) {
@@ -252,7 +252,7 @@ int main(int argc, char *argv[]) {
} else if (r > 0)
log_info("Not all swaps deactivated, %d left.", r);
else
- log_error("Failed to deactivate swaps: %s", strerror(-r));
+ log_error_errno(-r, "Failed to deactivate swaps: %m");
}
if (need_loop_detach) {
@@ -264,7 +264,7 @@ int main(int argc, char *argv[]) {
} else if (r > 0)
log_info("Not all loop devices detached, %d left.", r);
else
- log_error("Failed to detach loop devices: %s", strerror(-r));
+ log_error_errno(-r, "Failed to detach loop devices: %m");
}
if (need_dm_detach) {
@@ -276,7 +276,7 @@ int main(int argc, char *argv[]) {
} else if (r > 0)
log_info("Not all DM devices detached, %d left.", r);
else
- log_error("Failed to detach DM devices: %s", strerror(-r));
+ log_error_errno(-r, "Failed to detach DM devices: %m");
}
if (!need_umount && !need_swapoff && !need_loop_detach && !need_dm_detach) {
@@ -329,7 +329,7 @@ int main(int argc, char *argv[]) {
execv("/shutdown", argv);
log_error("Failed to execute shutdown binary: %m");
} else
- log_error("Failed to switch root to \"/run/initramfs\": %s", strerror(-r));
+ log_error_errno(-r, "Failed to switch root to \"/run/initramfs\": %m");
}
@@ -416,7 +416,7 @@ int main(int argc, char *argv[]) {
r = -errno;
error:
- log_emergency("Critical error while doing system shutdown: %s", strerror(-r));
+ log_emergency_errno(-r, "Critical error while doing system shutdown: %m");
freeze();
}
diff --git a/src/core/socket.c b/src/core/socket.c
index 96fe2d4a41..2ee0024590 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -1506,7 +1506,7 @@ static int socket_chown(Socket *s, pid_t *_pid) {
fail_child:
log_open();
- log_error("Failed to chown socket at step %s: %s", exit_status_to_string(ret, EXIT_STATUS_SYSTEMD), strerror(-r));
+ log_error_errno(-r, "Failed to chown socket at step %s: %m", exit_status_to_string(ret, EXIT_STATUS_SYSTEMD));
_exit(ret);
}
diff --git a/src/core/swap.c b/src/core/swap.c
index fd16104ebb..0384ebcdbb 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -1170,7 +1170,7 @@ static int swap_dispatch_io(sd_event_source *source, int fd, uint32_t revents, v
r = swap_load_proc_swaps(m, true);
if (r < 0) {
- log_error("Failed to reread /proc/swaps: %s", strerror(-r));
+ log_error_errno(-r, "Failed to reread /proc/swaps: %m");
/* Reset flags, just in case, for late calls */
LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_SWAP]) {
diff --git a/src/core/timer.c b/src/core/timer.c
index 1380443419..819a2608bd 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -148,7 +148,7 @@ static int timer_setup_persistent(Timer *t) {
r = get_home_dir(&h);
if (r < 0) {
- log_error("Failed to determine home directory: %s", strerror(-r));
+ log_error_errno(-r, "Failed to determine home directory: %m");
return r;
}
diff --git a/src/core/transaction.c b/src/core/transaction.c
index 652ac71094..118a242e6e 100644
--- a/src/core/transaction.c
+++ b/src/core/transaction.c
@@ -723,7 +723,7 @@ int transaction_activate(Transaction *tr, Manager *m, JobMode mode, sd_bus_error
/* Tenth step: apply changes */
r = transaction_apply(tr, m, mode);
if (r < 0) {
- log_warning("Failed to apply transaction: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to apply transaction: %m");
return r;
}
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
index 7c79ca3561..c1f167a189 100644
--- a/src/cryptsetup/cryptsetup-generator.c
+++ b/src/cryptsetup/cryptsetup-generator.c
@@ -255,7 +255,7 @@ static int create_disk(
"# Automatically generated by systemd-cryptsetup-generator \n\n"
"[Unit]\nJobTimeoutSec=0");
if (r < 0) {
- log_error("Failed to write device drop-in: %s", strerror(-r));
+ log_error_errno(-r, "Failed to write device drop-in: %m");
return r;
}
}
@@ -327,7 +327,7 @@ int main(int argc, char *argv[]) {
z = parse_proc_cmdline(parse_proc_cmdline_item);
if (z < 0)
- log_warning("Failed to parse kernel command line, ignoring: %s", strerror(-z));
+ log_warning_errno(-z, "Failed to parse kernel command line, ignoring: %m");
if (!arg_enabled) {
r = r2 = EXIT_SUCCESS;
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index b9e67fa63b..4afe53138f 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -281,7 +281,7 @@ static int get_password(const char *name, usec_t until, bool accept_cached, char
r = ask_password_auto(text, "drive-harddisk", id, until, accept_cached, passwords);
if (r < 0) {
- log_error("Failed to query password: %s", strerror(-r));
+ log_error_errno(-r, "Failed to query password: %m");
return r;
}
@@ -297,7 +297,7 @@ static int get_password(const char *name, usec_t until, bool accept_cached, char
r = ask_password_auto(text, "drive-harddisk", id, until, false, &passwords2);
if (r < 0) {
- log_error("Failed to query verification password: %s", strerror(-r));
+ log_error_errno(-r, "Failed to query verification password: %m");
return r;
}
@@ -355,7 +355,7 @@ static int attach_tcrypt(struct crypt_device *cd,
if (key_file) {
r = read_one_line_file(key_file, &passphrase);
if (r < 0) {
- log_error("Failed to read password file '%s': %s", key_file, strerror(-r));
+ log_error_errno(-r, "Failed to read password file '%s': %m", key_file);
return -EAGAIN;
}
@@ -439,7 +439,7 @@ static int attach_luks_or_plain(struct crypt_device *cd,
}
if (r < 0) {
- log_error("Loading of cryptographic parameters failed: %s", strerror(-r));
+ log_error_errno(-r, "Loading of cryptographic parameters failed: %m");
return r;
}
@@ -454,7 +454,7 @@ static int attach_luks_or_plain(struct crypt_device *cd,
key_file, arg_keyfile_size,
arg_keyfile_offset, flags);
if (r < 0) {
- log_error("Failed to activate with key file '%s': %s", key_file, strerror(-r));
+ log_error_errno(-r, "Failed to activate with key file '%s': %m", key_file);
return -EAGAIN;
}
} else {
@@ -567,7 +567,7 @@ int main(int argc, char *argv[]) {
k = crypt_init(&cd, argv[3]);
if (k) {
- log_error("crypt_init() failed: %s", strerror(-k));
+ log_error_errno(-k, "crypt_init() failed: %m");
goto finish;
}
@@ -623,7 +623,7 @@ int main(int argc, char *argv[]) {
key_file = NULL;
continue;
} else if (k != -EPERM) {
- log_error("Failed to activate: %s", strerror(-k));
+ log_error_errno(-k, "Failed to activate: %m");
goto finish;
}
@@ -641,7 +641,7 @@ int main(int argc, char *argv[]) {
k = crypt_init_by_name(&cd, argv[2]);
if (k) {
- log_error("crypt_init() failed: %s", strerror(-k));
+ log_error_errno(-k, "crypt_init() failed: %m");
goto finish;
}
@@ -649,7 +649,7 @@ int main(int argc, char *argv[]) {
k = crypt_deactivate(cd, argv[2]);
if (k < 0) {
- log_error("Failed to deactivate: %s", strerror(-k));
+ log_error_errno(-k, "Failed to deactivate: %m");
goto finish;
}
diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c
index 57af80c0e9..4ba1ad131d 100644
--- a/src/dbus1-generator/dbus1-generator.c
+++ b/src/dbus1-generator/dbus1-generator.c
@@ -103,7 +103,7 @@ static int create_dbus_files(
r = fflush_and_check(f);
if (r < 0) {
- log_error("Failed to write %s: %s", a, strerror(-r));
+ log_error_errno(-r, "Failed to write %s: %m", a);
return r;
}
@@ -140,7 +140,7 @@ static int create_dbus_files(
r = fflush_and_check(f);
if (r < 0) {
- log_error("Failed to write %s: %s", b, strerror(-r));
+ log_error_errno(-r, "Failed to write %s: %m", b);
return r;
}
@@ -332,7 +332,7 @@ int main(int argc, char *argv[]) {
type = "system";
units = SYSTEM_DATA_UNIT_PATH;
} else {
- log_error("Failed to determine whether we are running as user or system instance: %s", strerror(-r));
+ log_error_errno(-r, "Failed to determine whether we are running as user or system instance: %m");
return r;
}
diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c
index 5bbcd8fca7..ffafc4da24 100644
--- a/src/debug-generator/debug-generator.c
+++ b/src/debug-generator/debug-generator.c
@@ -152,7 +152,7 @@ int main(int argc, char *argv[]) {
r = parse_proc_cmdline(parse_proc_cmdline_item);
if (r < 0)
- log_warning("Failed to parse kernel command line, ignoring: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to parse kernel command line, ignoring: %m");
if (arg_debug_shell) {
r = strv_extend(&arg_wants, "debug-shell.service");
diff --git a/src/delta/delta.c b/src/delta/delta.c
index 25c4a0bcfc..2a1ad3d951 100644
--- a/src/delta/delta.c
+++ b/src/delta/delta.c
@@ -227,7 +227,7 @@ static int enumerate_dir_d(Hashmap *top, Hashmap *bottom, Hashmap *drops, const
r = get_files_in_directory(path, &list);
if (r < 0){
- log_error("Failed to enumerate %s: %s", path, strerror(-r));
+ log_error_errno(-r, "Failed to enumerate %s: %m", path);
return r;
}
diff --git a/src/detect-virt/detect-virt.c b/src/detect-virt/detect-virt.c
index ff5bee56f9..d25c48ebfe 100644
--- a/src/detect-virt/detect-virt.c
+++ b/src/detect-virt/detect-virt.c
@@ -131,7 +131,7 @@ int main(int argc, char *argv[]) {
v = detect_virtualization(&id);
if (v < 0) {
- log_error("Failed to check for virtualization: %s", strerror(-v));
+ log_error_errno(-v, "Failed to check for virtualization: %m");
return EXIT_FAILURE;
}
@@ -142,7 +142,7 @@ int main(int argc, char *argv[]) {
case ONLY_CONTAINER:
r = detect_container(&id);
if (r < 0) {
- log_error("Failed to check for container: %s", strerror(-r));
+ log_error_errno(-r, "Failed to check for container: %m");
return EXIT_FAILURE;
}
@@ -152,7 +152,7 @@ int main(int argc, char *argv[]) {
case ONLY_VM:
r = detect_vm(&id);
if (r < 0) {
- log_error("Failed to check for vm: %s", strerror(-r));
+ log_error_errno(-r, "Failed to check for vm: %m");
return EXIT_FAILURE;
}
diff --git a/src/efi-boot-generator/efi-boot-generator.c b/src/efi-boot-generator/efi-boot-generator.c
index d4d778036f..52d00c0443 100644
--- a/src/efi-boot-generator/efi-boot-generator.c
+++ b/src/efi-boot-generator/efi-boot-generator.c
@@ -80,7 +80,7 @@ int main(int argc, char *argv[]) {
log_debug("EFI loader partition unknown, exiting.");
return EXIT_SUCCESS;
} else if (r < 0) {
- log_error("Failed to read ESP partition UUID: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read ESP partition UUID: %m");
return EXIT_FAILURE;
}
diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c
index 93273d903c..1f11a2aec6 100644
--- a/src/firstboot/firstboot.c
+++ b/src/firstboot/firstboot.c
@@ -98,7 +98,7 @@ static void print_welcome(void) {
}
if (r < 0 && r != -ENOENT)
- log_warning("Failed to read os-release file: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to read os-release file: %m");
printf("\nWelcome to your new installation of %s!\nPlease configure a few basic system settings:\n\n",
isempty(pretty_name) ? "Linux" : pretty_name);
@@ -167,7 +167,7 @@ static int prompt_loop(const char *text, char **l, bool (*is_valid)(const char *
r = ask_string(&p, "%s %s (empty to skip): ", draw_special_char(DRAW_TRIANGULAR_BULLET), text);
if (r < 0) {
- log_error("Failed to query user: %s", strerror(-r));
+ log_error_errno(-r, "Failed to query user: %m");
return r;
}
@@ -220,7 +220,7 @@ static int prompt_locale(void) {
r = get_locales(&locales);
if (r < 0) {
- log_error("Cannot query locales list: %s", strerror(-r));
+ log_error_errno(-r, "Cannot query locales list: %m");
return r;
}
@@ -263,7 +263,7 @@ static int process_locale(void) {
r = copy_file("/etc/locale.conf", etc_localeconf, 0, 0644);
if (r != -ENOENT) {
if (r < 0) {
- log_error("Failed to copy %s: %s", etc_localeconf, strerror(-r));
+ log_error_errno(-r, "Failed to copy %s: %m", etc_localeconf);
return r;
}
@@ -289,7 +289,7 @@ static int process_locale(void) {
mkdir_parents(etc_localeconf, 0755);
r = write_env_file(etc_localeconf, locales);
if (r < 0) {
- log_error("Failed to write %s: %s", etc_localeconf, strerror(-r));
+ log_error_errno(-r, "Failed to write %s: %m", etc_localeconf);
return r;
}
@@ -309,7 +309,7 @@ static int prompt_timezone(void) {
r = get_timezones(&zones);
if (r < 0) {
- log_error("Cannot query timezone list: %s", strerror(-r));
+ log_error_errno(-r, "Cannot query timezone list: %m");
return r;
}
@@ -343,7 +343,7 @@ static int process_timezone(void) {
r = readlink_malloc("/etc/localtime", &p);
if (r != -ENOENT) {
if (r < 0) {
- log_error("Failed to read host timezone: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read host timezone: %m");
return r;
}
@@ -394,7 +394,7 @@ static int prompt_hostname(void) {
r = ask_string(&h, "%s Please enter hostname for new system (empty to skip): ", draw_special_char(DRAW_TRIANGULAR_BULLET));
if (r < 0) {
- log_error("Failed to query hostname: %s", strerror(-r));
+ log_error_errno(-r, "Failed to query hostname: %m");
return r;
}
@@ -434,7 +434,7 @@ static int process_hostname(void) {
mkdir_parents(etc_hostname, 0755);
r = write_string_file(etc_hostname, arg_hostname);
if (r < 0) {
- log_error("Failed to write %s: %s", etc_hostname, strerror(-r));
+ log_error_errno(-r, "Failed to write %s: %m", etc_hostname);
return r;
}
@@ -457,7 +457,7 @@ static int process_machine_id(void) {
mkdir_parents(etc_machine_id, 0755);
r = write_string_file(etc_machine_id, sd_id128_to_string(arg_machine_id, id));
if (r < 0) {
- log_error("Failed to write machine id: %s", strerror(-r));
+ log_error_errno(-r, "Failed to write machine id: %m");
return r;
}
@@ -490,7 +490,7 @@ static int prompt_root_password(void) {
r = ask_password_tty(msg1, 0, false, NULL, &a);
if (r < 0) {
- log_error("Failed to query root password: %s", strerror(-r));
+ log_error_errno(-r, "Failed to query root password: %m");
return r;
}
@@ -501,7 +501,7 @@ static int prompt_root_password(void) {
r = ask_password_tty(msg2, 0, false, NULL, &b);
if (r < 0) {
- log_error("Failed to query root password: %s", strerror(-r));
+ log_error_errno(-r, "Failed to query root password: %m");
clear_string(a);
return r;
}
@@ -592,7 +592,7 @@ static int process_root_password(void) {
r = write_root_shadow(etc_shadow, p);
if (r < 0) {
- log_error("Failed to write %s: %s", etc_shadow, strerror(-r));
+ log_error_errno(-r, "Failed to write %s: %m", etc_shadow);
return r;
}
@@ -610,7 +610,7 @@ static int process_root_password(void) {
r = dev_urandom(raw, 16);
if (r < 0) {
- log_error("Failed to get salt: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get salt: %m");
return r;
}
@@ -636,7 +636,7 @@ static int process_root_password(void) {
r = write_root_shadow(etc_shadow, &item);
if (r < 0) {
- log_error("Failed to write %s: %s", etc_shadow, strerror(-r));
+ log_error_errno(-r, "Failed to write %s: %m", etc_shadow);
return r;
}
@@ -804,7 +804,7 @@ static int parse_argv(int argc, char *argv[]) {
r = read_one_line_file(optarg, &arg_root_password);
if (r < 0) {
- log_error("Failed to read %s: %s", optarg, strerror(-r));
+ log_error_errno(-r, "Failed to read %s: %m", optarg);
return r;
}
@@ -871,7 +871,7 @@ static int parse_argv(int argc, char *argv[]) {
r = sd_id128_randomize(&arg_machine_id);
if (r < 0) {
- log_error("Failed to generate randomized machine ID: %s", strerror(-r));
+ log_error_errno(-r, "Failed to generate randomized machine ID: %m");
return r;
}
diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
index 556221759a..f5158735fa 100644
--- a/src/fsck/fsck.c
+++ b/src/fsck/fsck.c
@@ -54,7 +54,7 @@ static void start_target(const char *target) {
r = bus_open_system_systemd(&bus);
if (r < 0) {
- log_error("Failed to get D-Bus connection: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get D-Bus connection: %m");
return;
}
@@ -238,7 +238,7 @@ int main(int argc, char *argv[]) {
q = parse_proc_cmdline(parse_proc_cmdline_item);
if (q < 0)
- log_warning("Failed to parse kernel command line, ignoring: %s", strerror(-q));
+ log_warning_errno(-q, "Failed to parse kernel command line, ignoring: %m");
test_files();
@@ -309,7 +309,7 @@ int main(int argc, char *argv[]) {
log_info("fsck.%s doesn't exist, not checking file system on %s", type, device);
return EXIT_SUCCESS;
} else if (r < 0)
- log_warning("fsck.%s cannot be used for %s: %s", type, device, strerror(-r));
+ log_warning_errno(-r, "fsck.%s cannot be used for %s: %m", type, device);
}
if (arg_show_progress)
@@ -365,7 +365,7 @@ int main(int argc, char *argv[]) {
q = wait_for_terminate(pid, &status);
if (q < 0) {
- log_error("waitid(): %s", strerror(-q));
+ log_error_errno(-q, "waitid(): %m");
goto finish;
}
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 14e664236e..1863ab8e89 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -134,7 +134,7 @@ static int add_swap(
r = fflush_and_check(f);
if (r < 0) {
- log_error("Failed to write unit file %s: %s", unit, strerror(-r));
+ log_error_errno(-r, "Failed to write unit file %s: %m", unit);
return r;
}
@@ -600,7 +600,7 @@ int main(int argc, char *argv[]) {
r = parse_proc_cmdline(parse_proc_cmdline_item);
if (r < 0)
- log_warning("Failed to parse kernel command line, ignoring: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to parse kernel command line, ignoring: %m");
/* Always honour root= and usr= in the kernel command line if we are in an initrd */
if (in_initrd()) {
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
index 9251ddff75..7deee3fc44 100644
--- a/src/gpt-auto-generator/gpt-auto-generator.c
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
@@ -205,7 +205,7 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
"[Unit]\n"
"JobTimeoutSec=0\n"); /* the binary handles timeouts anyway */
if (r < 0) {
- log_error("Failed to write device drop-in: %s", strerror(-r));
+ log_error_errno(-r, "Failed to write device drop-in: %m");
return r;
}
@@ -488,7 +488,7 @@ static int enumerate_partitions(dev_t devnum) {
r = udev_enumerate_scan_devices(e);
if (r < 0) {
- log_error("Failed to enumerate partitions on %s: %s", node, strerror(-r));
+ log_error_errno(-r, "Failed to enumerate partitions on %s: %m", node);
return r;
}
@@ -713,7 +713,7 @@ static int add_root_mount(void) {
log_debug("EFI loader partition unknown, exiting.");
return 0;
} else if (r < 0) {
- log_error("Failed to read ESP partition UUID: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read ESP partition UUID: %m");
return r;
}
@@ -740,7 +740,7 @@ static int add_mounts(void) {
r = get_block_device("/", &devno);
if (r < 0) {
- log_error("Failed to determine block device of root file system: %s", strerror(-r));
+ log_error_errno(-r, "Failed to determine block device of root file system: %m");
return r;
} else if (r == 0) {
log_debug("Root file system not on a (single) block device.");
@@ -774,7 +774,7 @@ int main(int argc, char *argv[]) {
r = parse_proc_cmdline(parse_proc_cmdline_item);
if (r < 0)
- log_warning("Failed to parse kernel command line, ignoring: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to parse kernel command line, ignoring: %m");
if (!arg_enabled) {
log_debug("Disabled, exiting.");
diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c
index 41f65d984e..a2768364ea 100644
--- a/src/hibernate-resume/hibernate-resume-generator.c
+++ b/src/hibernate-resume/hibernate-resume-generator.c
@@ -88,7 +88,7 @@ int main(int argc, char *argv[]) {
r = parse_proc_cmdline(parse_proc_cmdline_item);
if (r < 0)
- log_warning("Failed to parse kernel command line, ignoring: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to parse kernel command line, ignoring: %m");
r = process_resume();
free(arg_resume_dev);
diff --git a/src/hibernate-resume/hibernate-resume.c b/src/hibernate-resume/hibernate-resume.c
index b234a0b49a..262516e0f9 100644
--- a/src/hibernate-resume/hibernate-resume.c
+++ b/src/hibernate-resume/hibernate-resume.c
@@ -69,7 +69,7 @@ int main(int argc, char *argv[]) {
r = write_string_file("/sys/power/resume", major_minor);
if (r < 0) {
- log_error("Failed to write '%s' to /sys/power/resume: %s", major_minor, strerror(-r));
+ log_error_errno(-r, "Failed to write '%s' to /sys/power/resume: %m", major_minor);
return EXIT_FAILURE;
}
diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c
index e48736920f..abbd787d2b 100644
--- a/src/hostname/hostnamectl.c
+++ b/src/hostname/hostnamectl.c
@@ -529,7 +529,7 @@ int main(int argc, char *argv[]) {
r = bus_open_transport(arg_transport, arg_host, false, &bus);
if (r < 0) {
- log_error("Failed to create bus connection: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create bus connection: %m");
goto finish;
}
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index 0123922c4a..edd5c8da37 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -442,7 +442,7 @@ static int method_set_hostname(sd_bus *bus, sd_bus_message *m, void *userdata, s
r = context_update_kernel_hostname(c);
if (r < 0) {
- log_error("Failed to set host name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set host name: %m");
return sd_bus_error_set_errnof(error, r, "Failed to set hostname: %s", strerror(-r));
}
@@ -494,13 +494,13 @@ static int method_set_static_hostname(sd_bus *bus, sd_bus_message *m, void *user
r = context_update_kernel_hostname(c);
if (r < 0) {
- log_error("Failed to set host name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set host name: %m");
return sd_bus_error_set_errnof(error, r, "Failed to set hostname: %s", strerror(-r));
}
r = context_write_data_static_hostname(c);
if (r < 0) {
- log_error("Failed to write static host name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to write static host name: %m");
return sd_bus_error_set_errnof(error, r, "Failed to set static hostname: %s", strerror(-r));
}
@@ -573,7 +573,7 @@ static int set_machine_info(Context *c, sd_bus *bus, sd_bus_message *m, int prop
r = context_write_data_machine_info(c);
if (r < 0) {
- log_error("Failed to write machine info: %s", strerror(-r));
+ log_error_errno(-r, "Failed to write machine info: %m");
return sd_bus_error_set_errnof(error, r, "Failed to write machine info: %s", strerror(-r));
}
@@ -646,25 +646,25 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
r = sd_bus_default_system(&bus);
if (r < 0) {
- log_error("Failed to get system bus connection: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get system bus connection: %m");
return r;
}
r = sd_bus_add_object_vtable(bus, NULL, "/org/freedesktop/hostname1", "org.freedesktop.hostname1", hostname_vtable, c);
if (r < 0) {
- log_error("Failed to register object: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register object: %m");
return r;
}
r = sd_bus_request_name(bus, "org.freedesktop.hostname1", 0);
if (r < 0) {
- log_error("Failed to register name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register name: %m");
return r;
}
r = sd_bus_attach_event(bus, event, 0);
if (r < 0) {
- log_error("Failed to attach bus to event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to attach bus to event loop: %m");
return r;
}
@@ -701,7 +701,7 @@ int main(int argc, char *argv[]) {
r = sd_event_default(&event);
if (r < 0) {
- log_error("Failed to allocate event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate event loop: %m");
goto finish;
}
@@ -713,13 +713,13 @@ int main(int argc, char *argv[]) {
r = context_read_data(&context);
if (r < 0) {
- log_error("Failed to read hostname and machine information: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read hostname and machine information: %m");
goto finish;
}
r = bus_event_loop_with_idle(event, bus, "org.freedesktop.hostname1", DEFAULT_EXIT_USEC, NULL, NULL);
if (r < 0) {
- log_error("Failed to run event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to run event loop: %m");
goto finish;
}
diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c
index f1c2b8dfb4..4c7efa74a3 100644
--- a/src/initctl/initctl.c
+++ b/src/initctl/initctl.c
@@ -328,7 +328,7 @@ static int server_init(Server *s, unsigned n_sockets) {
r = bus_open_system_systemd(&s->bus);
if (r < 0) {
- log_error("Failed to get D-Bus connection: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get D-Bus connection: %m");
r = -EIO;
goto fail;
}
@@ -355,7 +355,7 @@ static int process_event(Server *s, struct epoll_event *ev) {
f = (Fifo*) ev->data.ptr;
r = fifo_process(f);
if (r < 0) {
- log_info("Got error on fifo: %s", strerror(-r));
+ log_info_errno(-r, "Got error on fifo: %m");
fifo_free(f);
return r;
}
@@ -385,7 +385,7 @@ int main(int argc, char *argv[]) {
n = sd_listen_fds(true);
if (n < 0) {
- log_error("Failed to read listening file descriptors from environment: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read listening file descriptors from environment: %m");
return EXIT_FAILURE;
}
diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c
index db81fe3ca3..499a5fc6a2 100644
--- a/src/journal-remote/journal-gatewayd.c
+++ b/src/journal-remote/journal-gatewayd.c
@@ -155,14 +155,14 @@ static ssize_t request_reader_entries(
r = sd_journal_next(m->journal);
if (r < 0) {
- log_error("Failed to advance journal pointer: %s", strerror(-r));
+ log_error_errno(-r, "Failed to advance journal pointer: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
} else if (r == 0) {
if (m->follow) {
r = sd_journal_wait(m->journal, (uint64_t) -1);
if (r < 0) {
- log_error("Couldn't wait for journal event: %s", strerror(-r));
+ log_error_errno(-r, "Couldn't wait for journal event: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
@@ -177,7 +177,7 @@ static ssize_t request_reader_entries(
r = sd_journal_test_cursor(m->journal, m->cursor);
if (r < 0) {
- log_error("Failed to test cursor: %s", strerror(-r));
+ log_error_errno(-r, "Failed to test cursor: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
@@ -205,7 +205,7 @@ static ssize_t request_reader_entries(
r = output_journal(m->tmp, m->journal, m->mode, 0, OUTPUT_FULL_WIDTH, NULL);
if (r < 0) {
- log_error("Failed to serialize item: %s", strerror(-r));
+ log_error_errno(-r, "Failed to serialize item: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
@@ -394,7 +394,7 @@ static int request_parse_arguments_iterator(
r = sd_id128_get_boot(&bid);
if (r < 0) {
- log_error("Failed to get boot ID: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get boot ID: %m");
return MHD_NO;
}
@@ -543,7 +543,7 @@ static ssize_t request_reader_fields(
r = sd_journal_enumerate_unique(m->journal, &d, &l);
if (r < 0) {
- log_error("Failed to advance field index: %s", strerror(-r));
+ log_error_errno(-r, "Failed to advance field index: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
} else if (r == 0)
return MHD_CONTENT_READER_END_OF_STREAM;
@@ -566,7 +566,7 @@ static ssize_t request_reader_fields(
r = output_field(m->tmp, m->mode, d, l);
if (r < 0) {
- log_error("Failed to serialize item: %s", strerror(-r));
+ log_error_errno(-r, "Failed to serialize item: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
@@ -910,7 +910,7 @@ static int parse_argv(int argc, char *argv[]) {
}
r = read_full_file(optarg, &key_pem, NULL);
if (r < 0) {
- log_error("Failed to read key file: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read key file: %m");
return r;
}
assert(key_pem);
@@ -923,7 +923,7 @@ static int parse_argv(int argc, char *argv[]) {
}
r = read_full_file(optarg, &cert_pem, NULL);
if (r < 0) {
- log_error("Failed to read certificate file: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read certificate file: %m");
return r;
}
assert(cert_pem);
@@ -937,7 +937,7 @@ static int parse_argv(int argc, char *argv[]) {
}
r = read_full_file(optarg, &trust_pem, NULL);
if (r < 0) {
- log_error("Failed to read CA certificate file: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read CA certificate file: %m");
return r;
}
assert(trust_pem);
@@ -992,7 +992,7 @@ int main(int argc, char *argv[]) {
n = sd_listen_fds(1);
if (n < 0) {
- log_error("Failed to determine passed sockets: %s", strerror(-n));
+ log_error_errno(-n, "Failed to determine passed sockets: %m");
goto finish;
} else if (n > 1) {
log_error("Can't listen on more than one socket.");
diff --git a/src/journal-remote/journal-remote-write.c b/src/journal-remote/journal-remote-write.c
index 0139f851a5..ac59cb7a17 100644
--- a/src/journal-remote/journal-remote-write.c
+++ b/src/journal-remote/journal-remote-write.c
@@ -153,7 +153,7 @@ int writer_write(Writer *w,
return 1;
}
- log_debug("%s: Write failed, rotating: %s", w->journal->path, strerror(-r));
+ log_debug_errno(-r, "%s: Write failed, rotating: %m", w->journal->path);
r = do_rotate(&w->journal, compress, seal);
if (r < 0)
return r;
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index b3f5c828dd..d2050eff9f 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -151,13 +151,13 @@ static int spawn_getter(const char *getter, const char *url) {
assert(getter);
r = strv_split_quoted(&words, getter, false);
if (r < 0) {
- log_error("Failed to split getter option: %s", strerror(-r));
+ log_error_errno(-r, "Failed to split getter option: %m");
return r;
}
r = strv_extend(&words, url);
if (r < 0) {
- log_error("Failed to create command line: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create command line: %m");
return r;
}
@@ -400,7 +400,7 @@ static int add_source(RemoteServer *s, int fd, char* name, bool own_name) {
r = sd_event_source_set_description(source->event, name);
if (r < 0) {
- log_error("Failed to set source name for fd:%d: %s", fd, strerror(-r));
+ log_error_errno(-r, "Failed to set source name for fd:%d: %m", fd);
goto error;
}
@@ -662,7 +662,7 @@ static int setup_microhttpd_server(RemoteServer *s,
r = fd_nonblock(fd, true);
if (r < 0) {
- log_error("Failed to make fd:%d nonblocking: %s", fd, strerror(-r));
+ log_error_errno(-r, "Failed to make fd:%d nonblocking: %m", fd);
return r;
}
@@ -720,13 +720,13 @@ static int setup_microhttpd_server(RemoteServer *s,
epoll_fd, EPOLLIN,
dispatch_http_event, d);
if (r < 0) {
- log_error("Failed to add event callback: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add event callback: %m");
goto error;
}
r = sd_event_source_set_description(d->event, "epoll-fd");
if (r < 0) {
- log_error("Failed to set source name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set source name: %m");
goto error;
}
@@ -738,7 +738,7 @@ static int setup_microhttpd_server(RemoteServer *s,
r = hashmap_put(s->daemons, &d->fd, d);
if (r < 0) {
- log_error("Failed to add daemon to hashmap: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add daemon to hashmap: %m");
goto error;
}
@@ -841,7 +841,7 @@ static int remoteserver_init(RemoteServer *s,
r = sd_event_default(&s->events);
if (r < 0) {
- log_error("Failed to allocate event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate event loop: %m");
return r;
}
@@ -882,7 +882,7 @@ static int remoteserver_init(RemoteServer *s,
r = getnameinfo_pretty(fd, &hostname);
if (r < 0) {
- log_error("Failed to retrieve remote name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to retrieve remote name: %m");
return r;
}
@@ -1051,7 +1051,7 @@ static int dispatch_raw_source_event(sd_event_source *event,
} else if (r == -EAGAIN) {
return 0;
} else if (r < 0) {
- log_info("Closing connection: %s", strerror(-r));
+ log_info_errno(-r, "Closing connection: %m");
remove_source(server, fd);
return 0;
} else
@@ -1084,7 +1084,7 @@ static int accept_connection(const char* type, int fd,
r = socket_address_print(addr, &a);
if (r < 0) {
- log_error("socket_address_print(): %s", strerror(-r));
+ log_error_errno(-r, "socket_address_print(): %m");
close(fd2);
return r;
}
@@ -1542,7 +1542,7 @@ int main(int argc, char **argv) {
r = sd_event_set_watchdog(s.events, true);
if (r < 0)
- log_error("Failed to enable watchdog: %s", strerror(-r));
+ log_error_errno(-r, "Failed to enable watchdog: %m");
else
log_debug("Watchdog is %s.", r > 0 ? "enabled" : "disabled");
@@ -1561,7 +1561,7 @@ int main(int argc, char **argv) {
r = sd_event_run(s.events, -1);
if (r < 0) {
- log_error("Failed to run event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to run event loop: %m");
break;
}
}
diff --git a/src/journal-remote/journal-upload-journal.c b/src/journal-remote/journal-upload-journal.c
index 1cd52db2c1..290cfb9f56 100644
--- a/src/journal-remote/journal-upload-journal.c
+++ b/src/journal-remote/journal-upload-journal.c
@@ -26,7 +26,7 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
r = sd_journal_get_cursor(u->journal, &u->current_cursor);
if (r < 0) {
- log_error("Failed to get cursor: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get cursor: %m");
return r;
}
@@ -52,7 +52,7 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
r = sd_journal_get_realtime_usec(u->journal, &realtime);
if (r < 0) {
- log_error("Failed to get realtime timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get realtime timestamp: %m");
return r;
}
@@ -79,7 +79,7 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
r = sd_journal_get_monotonic_usec(u->journal, &monotonic, &boot_id);
if (r < 0) {
- log_error("Failed to get monotonic timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get monotonic timestamp: %m");
return r;
}
@@ -106,7 +106,7 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
r = sd_journal_get_monotonic_usec(u->journal, NULL, &boot_id);
if (r < 0) {
- log_error("Failed to get monotonic timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get monotonic timestamp: %m");
return r;
}
@@ -305,7 +305,7 @@ static int process_journal_input(Uploader *u, int skip) {
r = sd_journal_next_skip(u->journal, skip);
if (r < 0) {
- log_error("Failed to skip to next entry: %s", strerror(-r));
+ log_error_errno(-r, "Failed to skip to next entry: %m");
return r;
} else if (r < skip)
return 0;
@@ -321,7 +321,7 @@ int check_journal_input(Uploader *u) {
r = sd_journal_process(u->journal);
if (r < 0) {
- log_error("Failed to process journal: %s", strerror(-r));
+ log_error_errno(-r, "Failed to process journal: %m");
close_journal_input(u);
return r;
}
@@ -364,7 +364,7 @@ int open_journal_for_upload(Uploader *u,
if (follow) {
fd = sd_journal_get_fd(j);
if (fd < 0) {
- log_error("sd_journal_get_fd failed: %s", strerror(-fd));
+ log_error_errno(-fd, "sd_journal_get_fd failed: %m");
return fd;
}
@@ -380,7 +380,7 @@ int open_journal_for_upload(Uploader *u,
r = sd_event_add_io(u->events, &u->input_event,
fd, events, dispatch_journal_input, u);
if (r < 0) {
- log_error("Failed to register input event: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register input event: %m");
return r;
}
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c
index 9f13ffdbfe..36c0241d02 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -147,7 +147,7 @@ static int update_cursor_state(Uploader *u) {
finish:
if (r < 0)
- log_error("Failed to save state %s: %s", u->state_file, strerror(-r));
+ log_error_errno(-r, "Failed to save state %s: %m", u->state_file);
return r;
}
@@ -375,7 +375,7 @@ static int open_file_for_upload(Uploader *u, const char *filename) {
fd, EPOLLIN, dispatch_fd_input, u);
if (r < 0) {
if (r != -EPERM || arg_follow > 0) {
- log_error("Failed to register input event: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register input event: %m");
return r;
}
@@ -459,13 +459,13 @@ static int setup_uploader(Uploader *u, const char *url, const char *state_file)
r = sd_event_default(&u->events);
if (r < 0) {
- log_error("sd_event_default failed: %s", strerror(-r));
+ log_error_errno(-r, "sd_event_default failed: %m");
return r;
}
r = setup_signals(u);
if (r < 0) {
- log_error("Failed to set up signals: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set up signals: %m");
return r;
}
@@ -702,7 +702,7 @@ static int parse_argv(int argc, char *argv[]) {
case ARG_FILE:
r = glob_extend(&arg_file, optarg);
if (r < 0) {
- log_error("Failed to add paths: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add paths: %m");
return r;
};
break;
@@ -869,7 +869,7 @@ int main(int argc, char **argv) {
r = sd_event_run(u.events, u.timeout);
if (r < 0) {
- log_error("Failed to run event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to run event loop: %m");
break;
}
}
diff --git a/src/journal-remote/microhttpd-util.c b/src/journal-remote/microhttpd-util.c
index 5dae10bd80..3df34b2323 100644
--- a/src/journal-remote/microhttpd-util.c
+++ b/src/journal-remote/microhttpd-util.c
@@ -171,14 +171,14 @@ static int verify_cert_authorized(gnutls_session_t session) {
r = gnutls_certificate_verify_peers2(session, &status);
if (r < 0) {
- log_error("gnutls_certificate_verify_peers2 failed: %s", strerror(-r));
+ log_error_errno(-r, "gnutls_certificate_verify_peers2 failed: %m");
return r;
}
type = gnutls_certificate_type_get(session);
r = gnutls_certificate_verification_status_print(status, type, &out, 0);
if (r < 0) {
- log_error("gnutls_certificate_verification_status_print failed: %s", strerror(-r));
+ log_error_errno(-r, "gnutls_certificate_verification_status_print failed: %m");
return r;
}
diff --git a/src/journal/cat.c b/src/journal/cat.c
index 627c0624a5..955c85b4f9 100644
--- a/src/journal/cat.c
+++ b/src/journal/cat.c
@@ -134,7 +134,7 @@ int main(int argc, char *argv[]) {
fd = sd_journal_stream_fd(arg_identifier, arg_priority, arg_level_prefix);
if (fd < 0) {
- log_error("Failed to create stream fd: %s", strerror(-fd));
+ log_error_errno(-fd, "Failed to create stream fd: %m");
r = fd;
goto finish;
}
@@ -164,7 +164,7 @@ int main(int argc, char *argv[]) {
if (saved_stderr >= 0)
dup3(saved_stderr, STDERR_FILENO, 0);
- log_error("Failed to execute process: %s", strerror(-r));
+ log_error_errno(-r, "Failed to execute process: %m");
finish:
safe_close(fd);
diff --git a/src/journal/catalog.c b/src/journal/catalog.c
index 41d450b154..bcb3258cee 100644
--- a/src/journal/catalog.c
+++ b/src/journal/catalog.c
@@ -342,7 +342,7 @@ static long write_catalog(const char *database, Hashmap *h, struct strbuf *sb,
r = mkdir_p(d, 0775);
if (r < 0) {
- log_error("Recursive mkdir %s: %s", d, strerror(-r));
+ log_error_errno(-r, "Recursive mkdir %s: %m", d);
return r;
}
@@ -422,7 +422,7 @@ int catalog_update(const char* database, const char* root, const char* const* di
r = conf_files_list_strv(&files, ".catalog", root, dirs);
if (r < 0) {
- log_error("Failed to get catalog files: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get catalog files: %m");
goto finish;
}
@@ -463,7 +463,7 @@ int catalog_update(const char* database, const char* root, const char* const* di
r = write_catalog(database, h, sb, items, n);
if (r < 0)
- log_error("Failed to write %s: %s", database, strerror(-r));
+ log_error_errno(-r, "Failed to write %s: %m", database);
else
log_debug("%s: wrote %u items, with %zu bytes of strings, %ld total size.",
database, n, sb->len, r);
diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index e80b2f7c79..af155b487f 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -313,7 +313,7 @@ static int save_external_coredump(
r = make_filename(info, &fn);
if (r < 0) {
- log_error("Failed to determine coredump file name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to determine coredump file name: %m");
return r;
}
@@ -337,7 +337,7 @@ static int save_external_coredump(
log_error("Not enough disk space for coredump of %s (%s), refusing.", info[INFO_PID], info[INFO_COMM]);
goto fail;
} else if (r < 0) {
- log_error("Failed to dump coredump to file: %s", strerror(-r));
+ log_error_errno(-r, "Failed to dump coredump to file: %m");
goto fail;
}
@@ -379,7 +379,7 @@ static int save_external_coredump(
r = compress_stream(fd, fd_compressed, -1);
if (r < 0) {
- log_error("Failed to compress %s: %s", tmp_compressed, strerror(-r));
+ log_error_errno(-r, "Failed to compress %s: %m", tmp_compressed);
goto fail_compressed;
}
@@ -446,7 +446,7 @@ static int allocate_journal_field(int fd, size_t size, char **ret, size_t *ret_s
n = read(fd, field + 9, size);
if (n < 0) {
- log_error("Failed to read core data: %s", strerror(-n));
+ log_error_errno(-n, "Failed to read core data: %m");
return (int) n;
}
if ((size_t) n < size) {
@@ -841,7 +841,7 @@ int main(int argc, char* argv[]) {
else if (r == -EINVAL)
log_warning("Failed to generate stack trace: %s", dwfl_errmsg(dwfl_errno()));
else
- log_warning("Failed to generate stack trace: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to generate stack trace: %m");
}
if (!core_message)
@@ -868,7 +868,7 @@ log:
r = sd_journal_sendv(iovec, j);
if (r < 0)
- log_error("Failed to log coredump: %s", strerror(-r));
+ log_error_errno(-r, "Failed to log coredump: %m");
finish:
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c
index d4756fe67d..81b5462a41 100644
--- a/src/journal/coredumpctl.c
+++ b/src/journal/coredumpctl.c
@@ -73,7 +73,7 @@ static Set *new_matches(void) {
r = set_consume(set, tmp);
if (r < 0) {
- log_error("failed to add to set: %s", strerror(-r));
+ log_error_errno(-r, "failed to add to set: %m");
set_free(set);
return NULL;
}
@@ -110,13 +110,13 @@ static int add_match(Set *set, const char *match) {
log_debug("Adding pattern: %s", pattern);
r = set_consume(set, pattern);
if (r < 0) {
- log_error("Failed to add pattern: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add pattern: %m");
goto fail;
}
return 0;
fail:
- log_error("Failed to add match: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match: %m");
return r;
}
@@ -327,7 +327,7 @@ static int print_list(FILE* file, sd_journal *j, int had_legend) {
r = sd_journal_get_realtime_usec(j, &t);
if (r < 0) {
- log_error("Failed to get realtime timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get realtime timestamp: %m");
return r;
}
@@ -522,7 +522,7 @@ static int focus(sd_journal *j) {
if (r == 0)
r = sd_journal_previous(j);
if (r < 0) {
- log_error("Failed to search journal: %s", strerror(-r));
+ log_error_errno(-r, "Failed to search journal: %m");
return r;
}
if (r == 0) {
@@ -586,7 +586,7 @@ static int save_core(sd_journal *j, int fd, char **path, bool *unlink_temp) {
* compressed file (probably uncached). */
r = sd_journal_get_data(j, "COREDUMP_FILENAME", (const void**) &data, &len);
if (r < 0 && r != -ENOENT)
- log_warning("Failed to retrieve COREDUMP_FILENAME: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to retrieve COREDUMP_FILENAME: %m");
else if (r == 0)
retrieve(data, len, "COREDUMP_FILENAME", &filename);
@@ -655,7 +655,7 @@ static int save_core(sd_journal *j, int fd, char **path, bool *unlink_temp) {
r = decompress_stream(filename, fdf, fd, -1);
if (r < 0) {
- log_error("Failed to decompress %s: %s", filename, strerror(-r));
+ log_error_errno(-r, "Failed to decompress %s: %m", filename);
goto error;
}
#else
@@ -667,7 +667,7 @@ static int save_core(sd_journal *j, int fd, char **path, bool *unlink_temp) {
if (r == -ENOENT)
log_error("Cannot retrieve coredump from journal nor disk.");
else
- log_error("Failed to retrieve COREDUMP field: %s", strerror(-r));
+ log_error_errno(-r, "Failed to retrieve COREDUMP field: %m");
goto error;
}
@@ -705,7 +705,7 @@ static int dump_core(sd_journal* j) {
r = save_core(j, output ? fileno(output) : STDOUT_FILENO, NULL, NULL);
if (r < 0) {
- log_error("Coredump retrieval failed: %s", strerror(-r));
+ log_error_errno(-r, "Coredump retrieval failed: %m");
return r;
}
@@ -736,7 +736,7 @@ static int run_gdb(sd_journal *j) {
r = sd_journal_get_data(j, "COREDUMP_EXE", (const void**) &data, &len);
if (r < 0) {
- log_error("Failed to retrieve COREDUMP_EXE field: %s", strerror(-r));
+ log_error_errno(-r, "Failed to retrieve COREDUMP_EXE field: %m");
return r;
}
@@ -760,7 +760,7 @@ static int run_gdb(sd_journal *j) {
r = save_core(j, -1, &path, &unlink_path);
if (r < 0) {
- log_error("Failed to retrieve core: %s", strerror(-r));
+ log_error_errno(-r, "Failed to retrieve core: %m");
return r;
}
@@ -820,7 +820,7 @@ int main(int argc, char *argv[]) {
r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY);
if (r < 0) {
- log_error("Failed to open journal: %s", strerror(-r));
+ log_error_errno(-r, "Failed to open journal: %m");
goto end;
}
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 904880bff8..89fb89f0e6 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -502,7 +502,7 @@ static int parse_argv(int argc, char *argv[]) {
case ARG_FILE:
r = glob_extend(&arg_file, optarg);
if (r < 0) {
- log_error("Failed to add paths: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add paths: %m");
return r;
};
break;
@@ -750,7 +750,7 @@ static int generate_new_id128(void) {
r = sd_id128_randomize(&id);
if (r < 0) {
- log_error("Failed to generate ID: %s", strerror(-r));
+ log_error_errno(-r, "Failed to generate ID: %m");
return r;
}
@@ -852,7 +852,7 @@ static int add_matches(sd_journal *j, char **args) {
}
if (r < 0) {
- log_error("Failed to add match '%s': %s", *i, strerror(-r));
+ log_error_errno(-r, "Failed to add match '%s': %m", *i);
return r;
}
}
@@ -1030,7 +1030,7 @@ static int add_boot(sd_journal *j) {
r = get_boot_id_by_offset(j, &arg_boot_id, arg_boot_offset);
if (r < 0) {
if (sd_id128_equal(arg_boot_id, SD_ID128_NULL))
- log_error("Failed to look up boot %+i: %s", arg_boot_offset, strerror(-r));
+ log_error_errno(-r, "Failed to look up boot %+i: %m", arg_boot_offset);
else
log_error("Failed to look up boot ID "SD_ID128_FORMAT_STR"%+i: %s",
SD_ID128_FORMAT_VAL(arg_boot_id), arg_boot_offset, strerror(-r));
@@ -1041,7 +1041,7 @@ static int add_boot(sd_journal *j) {
r = sd_journal_add_match(j, match, sizeof(match) - 1);
if (r < 0) {
- log_error("Failed to add match: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match: %m");
return r;
}
@@ -1061,7 +1061,7 @@ static int add_dmesg(sd_journal *j) {
r = sd_journal_add_match(j, "_TRANSPORT=kernel", strlen("_TRANSPORT=kernel"));
if (r < 0) {
- log_error("Failed to add match: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match: %m");
return r;
}
@@ -1264,7 +1264,7 @@ static int add_priorities(sd_journal *j) {
r = sd_journal_add_match(j, match, strlen(match));
if (r < 0) {
- log_error("Failed to add match: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match: %m");
return r;
}
}
@@ -1328,13 +1328,13 @@ static int setup_keys(void) {
r = sd_id128_get_machine(&machine);
if (r < 0) {
- log_error("Failed to get machine ID: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get machine ID: %m");
return r;
}
r = sd_id128_get_boot(&boot);
if (r < 0) {
- log_error("Failed to get boot ID: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get boot ID: %m");
return r;
}
@@ -1683,7 +1683,7 @@ static int flush_to_var(void) {
* daemon and set up inotify to wait for the flushed file to appear */
r = bus_open_system_systemd(&bus);
if (r < 0) {
- log_error("Failed to get D-Bus connection: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get D-Bus connection: %m");
return r;
}
@@ -1726,13 +1726,13 @@ static int flush_to_var(void) {
r = fd_wait_for_event(watch_fd, POLLIN, USEC_INFINITY);
if (r < 0) {
- log_error("Failed to wait for event: %s", strerror(-r));
+ log_error_errno(-r, "Failed to wait for event: %m");
return r;
}
r = flush_fd(watch_fd);
if (r < 0) {
- log_error("Failed to flush inotify events: %s", strerror(-r));
+ log_error_errno(-r, "Failed to flush inotify events: %m");
return r;
}
}
@@ -1789,7 +1789,7 @@ int main(int argc, char *argv[]) {
if (arg_action == ACTION_UPDATE_CATALOG) {
r = catalog_update(database, arg_root, catalog_file_dirs);
if (r < 0)
- log_error("Failed to list catalog: %s", strerror(-r));
+ log_error_errno(-r, "Failed to list catalog: %m");
} else {
bool oneline = arg_action == ACTION_LIST_CATALOG;
@@ -1799,7 +1799,7 @@ int main(int argc, char *argv[]) {
else
r = catalog_list(stdout, database, oneline);
if (r < 0)
- log_error("Failed to list catalog: %s", strerror(-r));
+ log_error_errno(-r, "Failed to list catalog: %m");
}
goto finish;
@@ -1859,7 +1859,7 @@ int main(int argc, char *argv[]) {
q = journal_directory_vacuum(d->path, arg_vacuum_size, arg_vacuum_time, NULL, true);
if (q < 0) {
- log_error("Failed to vacuum: %s", strerror(-q));
+ log_error_errno(-q, "Failed to vacuum: %m");
r = q;
}
}
@@ -1887,25 +1887,25 @@ int main(int argc, char *argv[]) {
strv_free(arg_user_units);
if (r < 0) {
- log_error("Failed to add filter for units: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add filter for units: %m");
return EXIT_FAILURE;
}
r = add_syslog_identifier(j);
if (r < 0) {
- log_error("Failed to add filter for syslog identifiers: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add filter for syslog identifiers: %m");
return EXIT_FAILURE;
}
r = add_priorities(j);
if (r < 0) {
- log_error("Failed to add filter for priorities: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add filter for priorities: %m");
return EXIT_FAILURE;
}
r = add_matches(j, argv + optind);
if (r < 0) {
- log_error("Failed to add filters: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add filters: %m");
return EXIT_FAILURE;
}
@@ -1928,7 +1928,7 @@ int main(int argc, char *argv[]) {
r = sd_journal_query_unique(j, arg_field);
if (r < 0) {
- log_error("Failed to query unique data objects: %s", strerror(-r));
+ log_error_errno(-r, "Failed to query unique data objects: %m");
return EXIT_FAILURE;
}
@@ -1960,7 +1960,7 @@ int main(int argc, char *argv[]) {
if (arg_cursor || arg_after_cursor) {
r = sd_journal_seek_cursor(j, arg_cursor ?: arg_after_cursor);
if (r < 0) {
- log_error("Failed to seek to cursor: %s", strerror(-r));
+ log_error_errno(-r, "Failed to seek to cursor: %m");
return EXIT_FAILURE;
}
if (!arg_reverse)
@@ -1975,7 +1975,7 @@ int main(int argc, char *argv[]) {
} else if (arg_since_set && !arg_reverse) {
r = sd_journal_seek_realtime_usec(j, arg_since);
if (r < 0) {
- log_error("Failed to seek to date: %s", strerror(-r));
+ log_error_errno(-r, "Failed to seek to date: %m");
return EXIT_FAILURE;
}
r = sd_journal_next(j);
@@ -1983,7 +1983,7 @@ int main(int argc, char *argv[]) {
} else if (arg_until_set && arg_reverse) {
r = sd_journal_seek_realtime_usec(j, arg_until);
if (r < 0) {
- log_error("Failed to seek to date: %s", strerror(-r));
+ log_error_errno(-r, "Failed to seek to date: %m");
return EXIT_FAILURE;
}
r = sd_journal_previous(j);
@@ -1991,7 +1991,7 @@ int main(int argc, char *argv[]) {
} else if (arg_lines >= 0) {
r = sd_journal_seek_tail(j);
if (r < 0) {
- log_error("Failed to seek to tail: %s", strerror(-r));
+ log_error_errno(-r, "Failed to seek to tail: %m");
return EXIT_FAILURE;
}
@@ -2000,7 +2000,7 @@ int main(int argc, char *argv[]) {
} else if (arg_reverse) {
r = sd_journal_seek_tail(j);
if (r < 0) {
- log_error("Failed to seek to tail: %s", strerror(-r));
+ log_error_errno(-r, "Failed to seek to tail: %m");
return EXIT_FAILURE;
}
@@ -2009,7 +2009,7 @@ int main(int argc, char *argv[]) {
} else {
r = sd_journal_seek_head(j);
if (r < 0) {
- log_error("Failed to seek to head: %s", strerror(-r));
+ log_error_errno(-r, "Failed to seek to head: %m");
return EXIT_FAILURE;
}
@@ -2017,7 +2017,7 @@ int main(int argc, char *argv[]) {
}
if (r < 0) {
- log_error("Failed to iterate through journal: %s", strerror(-r));
+ log_error_errno(-r, "Failed to iterate through journal: %m");
return EXIT_FAILURE;
}
@@ -2030,7 +2030,7 @@ int main(int argc, char *argv[]) {
r = sd_journal_get_cutoff_realtime_usec(j, &start, &end);
if (r < 0) {
- log_error("Failed to get cutoff: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get cutoff: %m");
goto finish;
}
@@ -2055,7 +2055,7 @@ int main(int argc, char *argv[]) {
else
r = sd_journal_previous(j);
if (r < 0) {
- log_error("Failed to iterate through journal: %s", strerror(-r));
+ log_error_errno(-r, "Failed to iterate through journal: %m");
goto finish;
}
if (r == 0)
@@ -2067,7 +2067,7 @@ int main(int argc, char *argv[]) {
r = sd_journal_get_realtime_usec(j, &usec);
if (r < 0) {
- log_error("Failed to determine timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to determine timestamp: %m");
goto finish;
}
if (usec > arg_until)
@@ -2079,7 +2079,7 @@ int main(int argc, char *argv[]) {
r = sd_journal_get_realtime_usec(j, &usec);
if (r < 0) {
- log_error("Failed to determine timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to determine timestamp: %m");
goto finish;
}
if (usec < arg_since)
@@ -2124,7 +2124,7 @@ int main(int argc, char *argv[]) {
r = sd_journal_get_cursor(j, &cursor);
if (r < 0 && r != -EADDRNOTAVAIL)
- log_error("Failed to get cursor: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get cursor: %m");
else if (r >= 0)
printf("-- cursor: %s\n", cursor);
}
@@ -2134,7 +2134,7 @@ int main(int argc, char *argv[]) {
r = sd_journal_wait(j, (uint64_t) -1);
if (r < 0) {
- log_error("Couldn't wait for journal event: %s", strerror(-r));
+ log_error_errno(-r, "Couldn't wait for journal event: %m");
goto finish;
}
diff --git a/src/journal/journald-audit.c b/src/journal/journald-audit.c
index 341d74815d..f7c7acadd5 100644
--- a/src/journal/journald-audit.c
+++ b/src/journal/journald-audit.c
@@ -309,7 +309,7 @@ static int map_all_fields(
r = m->map(m->journal_field, &v, iov, n_iov_allocated, n_iov);
if (r < 0) {
- log_debug("Failed to parse audit array: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to parse audit array: %m");
return r;
}
@@ -323,7 +323,7 @@ static int map_all_fields(
if (!mapped) {
r = map_generic_field(prefix, &p, iov, n_iov_allocated, n_iov);
if (r < 0) {
- log_debug("Failed to parse audit array: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to parse audit array: %m");
return r;
}
@@ -548,14 +548,14 @@ int server_open_audit(Server *s) {
r = sd_event_add_io(s->event, &s->audit_event_source, s->audit_fd, EPOLLIN, process_datagram, s);
if (r < 0) {
- log_error("Failed to add audit fd to event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add audit fd to event loop: %m");
return r;
}
/* We are listening now, try to enable audit */
r = enable_audit(s->audit_fd, true);
if (r < 0)
- log_warning("Failed to issue audit enable call: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to issue audit enable call: %m");
return 0;
}
diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
index 126126b887..94866f10d3 100644
--- a/src/journal/journald-kmsg.c
+++ b/src/journal/journald-kmsg.c
@@ -413,13 +413,13 @@ int server_open_dev_kmsg(Server *s) {
goto fail;
}
- log_error("Failed to add /dev/kmsg fd to event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add /dev/kmsg fd to event loop: %m");
goto fail;
}
r = sd_event_source_set_priority(s->dev_kmsg_event_source, SD_EVENT_PRIORITY_IMPORTANT+10);
if (r < 0) {
- log_error("Failed to adjust priority of kmsg event source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to adjust priority of kmsg event source: %m");
goto fail;
}
diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
index 3c60b22eaf..6bb3dcd25d 100644
--- a/src/journal/journald-native.c
+++ b/src/journal/journald-native.c
@@ -405,7 +405,7 @@ void server_process_native_file(
n = pread(fd, p, st.st_size, 0);
if (n < 0)
- log_error("Failed to read file, ignoring: %s", strerror(-n));
+ log_error_errno(-n, "Failed to read file, ignoring: %m");
else if (n > 0)
server_process_native_message(s, p, n, ucred, tv, label, label_len);
}
@@ -463,7 +463,7 @@ int server_open_native_socket(Server*s) {
r = sd_event_add_io(s->event, &s->native_event_source, s->native_fd, EPOLLIN, process_datagram, s);
if (r < 0) {
- log_error("Failed to add native server fd to event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add native server fd to event loop: %m");
return r;
}
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 4fd2069d81..e2f433a5bb 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -204,7 +204,7 @@ void server_fix_perms(Server *s, JournalFile *f, uid_t uid) {
r = fchmod(f->fd, 0640);
if (r < 0)
- log_warning("Failed to fix access mode on %s, ignoring: %s", f->path, strerror(-r));
+ log_warning_errno(-r, "Failed to fix access mode on %s, ignoring: %m", f->path);
#ifdef HAVE_ACL
if (uid <= SYSTEM_UID_MAX)
@@ -348,19 +348,19 @@ void server_sync(Server *s) {
if (s->system_journal) {
r = journal_file_set_offline(s->system_journal);
if (r < 0)
- log_error("Failed to sync system journal: %s", strerror(-r));
+ log_error_errno(-r, "Failed to sync system journal: %m");
}
ORDERED_HASHMAP_FOREACH_KEY(f, k, s->user_journals, i) {
r = journal_file_set_offline(f);
if (r < 0)
- log_error("Failed to sync user journal: %s", strerror(-r));
+ log_error_errno(-r, "Failed to sync user journal: %m");
}
if (s->sync_event_source) {
r = sd_event_source_set_enabled(s->sync_event_source, SD_EVENT_OFF);
if (r < 0)
- log_error("Failed to disable sync timer source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to disable sync timer source: %m");
}
s->sync_scheduled = false;
@@ -377,7 +377,7 @@ static void do_vacuum(Server *s, char *ids, JournalFile *f, const char* path,
p = strappenda(path, ids);
r = journal_directory_vacuum(p, metrics->max_use, s->max_retention_usec, &s->oldest_file_usec, false);
if (r < 0 && r != -ENOENT)
- log_error("Failed to vacuum %s: %s", p, strerror(-r));
+ log_error_errno(-r, "Failed to vacuum %s: %m", p);
}
void server_vacuum(Server *s) {
@@ -391,7 +391,7 @@ void server_vacuum(Server *s) {
r = sd_id128_get_machine(&machine);
if (r < 0) {
- log_error("Failed to get machine ID: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get machine ID: %m");
return;
}
sd_id128_to_string(machine, ids);
@@ -511,7 +511,7 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned
for (i = 0; i < n; i++)
size += iovec[i].iov_len;
- log_error("Failed to write entry (%d items, %zu bytes), ignoring: %s", n, size, strerror(-r));
+ log_error_errno(-r, "Failed to write entry (%d items, %zu bytes), ignoring: %m", n, size);
return;
}
@@ -530,7 +530,7 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned
for (i = 0; i < n; i++)
size += iovec[i].iov_len;
- log_error("Failed to write entry (%d items, %zu bytes) despite vacuuming, ignoring: %s", n, size, strerror(-r));
+ log_error_errno(-r, "Failed to write entry (%d items, %zu bytes) despite vacuuming, ignoring: %m", n, size);
} else
server_schedule_sync(s, priority);
}
@@ -928,7 +928,7 @@ static int system_journal_open(Server *s, bool flush_requested) {
r = sd_id128_get_machine(&machine);
if (r < 0) {
- log_error("Failed to get machine id: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get machine id: %m");
return r;
}
@@ -958,7 +958,7 @@ static int system_journal_open(Server *s, bool flush_requested) {
server_fix_perms(s, s->system_journal, 0);
else if (r < 0) {
if (r != -ENOENT && r != -EROFS)
- log_warning("Failed to open system journal: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to open system journal: %m");
r = 0;
}
@@ -982,7 +982,7 @@ static int system_journal_open(Server *s, bool flush_requested) {
if (r < 0) {
if (r != -ENOENT)
- log_warning("Failed to open runtime journal: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to open runtime journal: %m");
r = 0;
}
@@ -1000,7 +1000,7 @@ static int system_journal_open(Server *s, bool flush_requested) {
free(fn);
if (r < 0) {
- log_error("Failed to open runtime journal: %s", strerror(-r));
+ log_error_errno(-r, "Failed to open runtime journal: %m");
return r;
}
}
@@ -1046,7 +1046,7 @@ int server_flush_to_var(Server *s) {
r = sd_journal_open(&j, SD_JOURNAL_RUNTIME_ONLY);
if (r < 0) {
- log_error("Failed to read runtime journal: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read runtime journal: %m");
return r;
}
@@ -1063,7 +1063,7 @@ int server_flush_to_var(Server *s) {
r = journal_file_move_to_object(f, OBJECT_ENTRY, f->current_offset, &o);
if (r < 0) {
- log_error("Can't read entry: %s", strerror(-r));
+ log_error_errno(-r, "Can't read entry: %m");
goto finish;
}
@@ -1072,7 +1072,7 @@ int server_flush_to_var(Server *s) {
continue;
if (!shall_try_append_again(s->system_journal, r)) {
- log_error("Can't write entry: %s", strerror(-r));
+ log_error_errno(-r, "Can't write entry: %m");
goto finish;
}
@@ -1088,7 +1088,7 @@ int server_flush_to_var(Server *s) {
log_debug("Retrying write.");
r = journal_file_copy_entry(f, s->system_journal, o, f->current_offset, NULL, NULL, NULL);
if (r < 0) {
- log_error("Can't write entry: %s", strerror(-r));
+ log_error_errno(-r, "Can't write entry: %m");
goto finish;
}
}
@@ -1311,7 +1311,7 @@ static int server_parse_proc_cmdline(Server *s) {
r = proc_cmdline(&line);
if (r < 0) {
- log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to read /proc/cmdline, ignoring: %m");
return 0;
}
@@ -1453,13 +1453,13 @@ static int server_open_hostname(Server *s) {
return 0;
}
- log_error("Failed to register hostname fd in event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register hostname fd in event loop: %m");
return r;
}
r = sd_event_source_set_priority(s->hostname_event_source, SD_EVENT_PRIORITY_IMPORTANT-10);
if (r < 0) {
- log_error("Failed to adjust priority of host name event source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to adjust priority of host name event source: %m");
return r;
}
@@ -1515,7 +1515,7 @@ int server_init(Server *s) {
r = sd_event_default(&s->event);
if (r < 0) {
- log_error("Failed to create event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create event loop: %m");
return r;
}
@@ -1523,7 +1523,7 @@ int server_init(Server *s) {
n = sd_listen_fds(true);
if (n < 0) {
- log_error("Failed to read listening file descriptors from environment: %s", strerror(-n));
+ log_error_errno(-n, "Failed to read listening file descriptors from environment: %m");
return n;
}
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
index 76580f8263..580f746249 100644
--- a/src/journal/journald-stream.c
+++ b/src/journal/journald-stream.c
@@ -408,13 +408,13 @@ static int stdout_stream_new(sd_event_source *es, int listen_fd, uint32_t revent
r = sd_event_add_io(s->event, &stream->event_source, fd, EPOLLIN, stdout_stream_process, stream);
if (r < 0) {
- log_error("Failed to add stream to event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add stream to event loop: %m");
goto fail;
}
r = sd_event_source_set_priority(stream->event_source, SD_EVENT_PRIORITY_NORMAL+5);
if (r < 0) {
- log_error("Failed to adjust stdout event source priority: %s", strerror(-r));
+ log_error_errno(-r, "Failed to adjust stdout event source priority: %m");
goto fail;
}
@@ -465,13 +465,13 @@ int server_open_stdout_socket(Server *s) {
r = sd_event_add_io(s->event, &s->stdout_event_source, s->stdout_fd, EPOLLIN, stdout_stream_new, s);
if (r < 0) {
- log_error("Failed to add stdout server fd to event source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add stdout server fd to event source: %m");
return r;
}
r = sd_event_source_set_priority(s->stdout_event_source, SD_EVENT_PRIORITY_NORMAL+10);
if (r < 0) {
- log_error("Failed to adjust priority of stdout server event source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to adjust priority of stdout server event source: %m");
return r;
}
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c
index ce6c2a3af4..b95f5da70e 100644
--- a/src/journal/journald-syslog.c
+++ b/src/journal/journald-syslog.c
@@ -467,7 +467,7 @@ int server_open_syslog_socket(Server *s) {
r = sd_event_add_io(s->event, &s->syslog_event_source, s->syslog_fd, EPOLLIN, process_datagram, s);
if (r < 0) {
- log_error("Failed to add syslog server fd to event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add syslog server fd to event loop: %m");
return r;
}
diff --git a/src/journal/journald-wall.c b/src/journal/journald-wall.c
index 1bdddb0db3..bb8ae8a85c 100644
--- a/src/journal/journald-wall.c
+++ b/src/journal/journald-wall.c
@@ -65,5 +65,5 @@ void server_forward_wall(
r = utmp_wall(l, "systemd-journald", NULL);
if (r < 0)
- log_debug("Failed to send wall message: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to send wall message: %m");
}
diff --git a/src/journal/journald.c b/src/journal/journald.c
index de40827d6a..09a832aaa6 100644
--- a/src/journal/journald.c
+++ b/src/journal/journald.c
@@ -104,7 +104,7 @@ int main(int argc, char *argv[]) {
r = sd_event_run(server.event, t);
if (r < 0) {
- log_error("Failed to run event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to run event loop: %m");
goto finish;
}
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index cf21c4d899..390e5831e1 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -884,7 +884,7 @@ static int real_journal_next(sd_journal *j, direction_t direction) {
r = next_beyond_location(j, f, direction, &o, &p);
if (r < 0) {
- log_debug("Can't iterate through %s, ignoring: %s", f->path, strerror(-r));
+ log_debug_errno(-r, "Can't iterate through %s, ignoring: %m", f->path);
remove_file_real(j, f);
continue;
} else if (r == 0)
@@ -1567,7 +1567,7 @@ static int add_root_directory(sd_journal *j, const char *p) {
r = add_directory(j, m->path, de->d_name);
if (r < 0)
- log_debug("Failed to add directory %s/%s: %s", m->path, de->d_name, strerror(-r));
+ log_debug_errno(-r, "Failed to add directory %s/%s: %m", m->path, de->d_name);
}
}
@@ -1810,7 +1810,7 @@ _public_ int sd_journal_open_files(sd_journal **ret, const char **paths, int fla
STRV_FOREACH(path, paths) {
r = add_any_file(j, *path);
if (r < 0) {
- log_error("Failed to open %s: %s", *path, strerror(-r));
+ log_error_errno(-r, "Failed to open %s: %m", *path);
goto fail;
}
}
@@ -2227,7 +2227,7 @@ static void process_inotify_event(sd_journal *j, struct inotify_event *e) {
r = remove_file(j, d->path, e->name);
if (r < 0)
- log_debug("Failed to remove file %s/%s: %s", d->path, e->name, strerror(-r));
+ log_debug_errno(-r, "Failed to remove file %s/%s: %m", d->path, e->name);
}
} else if (!d->is_root && e->len == 0) {
@@ -2237,7 +2237,7 @@ static void process_inotify_event(sd_journal *j, struct inotify_event *e) {
if (e->mask & (IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT)) {
r = remove_directory(j, d);
if (r < 0)
- log_debug("Failed to remove directory %s: %s", d->path, strerror(-r));
+ log_debug_errno(-r, "Failed to remove directory %s: %m", d->path);
}
@@ -2248,7 +2248,7 @@ static void process_inotify_event(sd_journal *j, struct inotify_event *e) {
if (e->mask & (IN_CREATE|IN_MOVED_TO|IN_MODIFY|IN_ATTRIB)) {
r = add_directory(j, d->path, e->name);
if (r < 0)
- log_debug("Failed to add directory %s/%s: %s", d->path, e->name, strerror(-r));
+ log_debug_errno(-r, "Failed to add directory %s/%s: %m", d->path, e->name);
}
}
diff --git a/src/journal/test-compress.c b/src/journal/test-compress.c
index 78b3203bef..85b033ad34 100644
--- a/src/journal/test-compress.c
+++ b/src/journal/test-compress.c
@@ -63,7 +63,7 @@ static void test_compress_decompress(int compression,
r = compress(data, data_len, compressed, &csize);
if (r == -ENOBUFS) {
- log_info("compression failed: %s", strerror(-r));
+ log_info_errno(-r, "compression failed: %m");
assert(may_fail);
} else {
assert(r == 0);
@@ -108,7 +108,7 @@ static void test_decompress_startswith(int compression,
r = compress(data, data_len, compressed, &csize);
if (r == -ENOBUFS) {
- log_info("compression failed: %s", strerror(-r));
+ log_info_errno(-r, "compression failed: %m");
assert(may_fail);
return;
}
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index 3da71a2cfb..e5ffa90d7f 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -685,7 +685,7 @@ int sd_dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) {
finish:
if (r < 0)
- log_error("Failed to save lease data %s: %s", lease_file, strerror(-r));
+ log_error_errno(-r, "Failed to save lease data %s: %m", lease_file);
return r;
}
@@ -725,7 +725,7 @@ int sd_dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
if (r == -ENOENT)
return 0;
- log_error("Failed to read %s: %s", lease_file, strerror(-r));
+ log_error_errno(-r, "Failed to read %s: %m", lease_file);
return r;
}
diff --git a/src/libsystemd-network/sd-pppoe.c b/src/libsystemd-network/sd-pppoe.c
index e142dec66d..9fb6f5382c 100644
--- a/src/libsystemd-network/sd-pppoe.c
+++ b/src/libsystemd-network/sd-pppoe.c
@@ -422,7 +422,7 @@ static int pppoe_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
case PPPOE_STATE_INITIALIZING:
r = pppoe_send_initiation(ppp);
if (r < 0)
- log_warning("PPPoE: sending PADI failed: %s", strerror(-r));
+ log_warning_errno(-r, "PPPoE: sending PADI failed: %m");
break;
case PPPOE_STATE_REQUESTING:
@@ -431,14 +431,14 @@ static int pppoe_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
r = pppoe_send_initiation(ppp);
if (r < 0)
- log_warning("PPPoE: sending PADI failed: %s", strerror(-r));
+ log_warning_errno(-r, "PPPoE: sending PADI failed: %m");
ppp->padr_resend_count = PPPOE_MAX_PADR_RESEND;
ppp->state = PPPOE_STATE_INITIALIZING;
} else {
r = pppoe_send_request(ppp);
if (r < 0)
- log_warning("PPPoE: sending PADR failed: %s", strerror(-r));
+ log_warning_errno(-r, "PPPoE: sending PADR failed: %m");
}
break;
@@ -716,7 +716,7 @@ static int pppoe_receive_message(sd_event_source *s, int fd, uint32_t revents, v
len = recvfrom(fd, packet, buflen, 0, &link.sa, &addrlen);
if (len < 0) {
- log_warning("PPPoE: could not receive message from raw socket: %s", strerror(-r));
+ log_warning_errno(-r, "PPPoE: could not receive message from raw socket: %m");
return 0;
} else if ((size_t)len < sizeof(struct pppoe_hdr))
return 0;
diff --git a/src/libsystemd-terminal/evcat.c b/src/libsystemd-terminal/evcat.c
index 9e8a262b79..08c872ab83 100644
--- a/src/libsystemd-terminal/evcat.c
+++ b/src/libsystemd-terminal/evcat.c
@@ -138,13 +138,13 @@ static int evcat_new(Evcat **out) {
r = sd_pid_get_session(getpid(), &e->session);
if (r < 0) {
- log_error("Cannot retrieve logind session: %s", strerror(-r));
+ log_error_errno(-r, "Cannot retrieve logind session: %m");
return r;
}
r = sd_session_get_seat(e->session, &e->seat);
if (r < 0) {
- log_error("Cannot retrieve seat of logind session: %s", strerror(-r));
+ log_error_errno(-r, "Cannot retrieve seat of logind session: %m");
return r;
}
@@ -319,14 +319,14 @@ static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *e
evcat_idev_fn,
e);
if (r < 0) {
- log_error("Cannot create idev session: %s", strerror(-r));
+ log_error_errno(-r, "Cannot create idev session: %m");
return r;
}
if (e->managed) {
r = sysview_session_take_control(ev->session_add.session);
if (r < 0) {
- log_error("Cannot request session control: %s", strerror(-r));
+ log_error_errno(-r, "Cannot request session control: %m");
return r;
}
}
@@ -346,7 +346,7 @@ static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *e
if (type == SYSVIEW_DEVICE_EVDEV) {
r = idev_session_add_evdev(e->idev_session, sysview_device_get_ud(d));
if (r < 0) {
- log_error("Cannot add evdev device to idev: %s", strerror(-r));
+ log_error_errno(-r, "Cannot add evdev device to idev: %m");
return r;
}
}
@@ -358,7 +358,7 @@ static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *e
if (type == SYSVIEW_DEVICE_EVDEV) {
r = idev_session_remove_evdev(e->idev_session, sysview_device_get_ud(d));
if (r < 0) {
- log_error("Cannot remove evdev device from idev: %s", strerror(-r));
+ log_error_errno(-r, "Cannot remove evdev device from idev: %m");
return r;
}
}
@@ -367,7 +367,7 @@ static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *e
case SYSVIEW_EVENT_SESSION_CONTROL:
r = ev->session_control.error;
if (r < 0) {
- log_error("Cannot acquire session control: %s", strerror(-r));
+ log_error_errno(-r, "Cannot acquire session control: %m");
return r;
}
diff --git a/src/libsystemd-terminal/idev-keyboard.c b/src/libsystemd-terminal/idev-keyboard.c
index ce9cc5318b..2179fd335d 100644
--- a/src/libsystemd-terminal/idev-keyboard.c
+++ b/src/libsystemd-terminal/idev-keyboard.c
@@ -377,7 +377,7 @@ static int kbdctx_set_locale(sd_bus *bus, const char *member, sd_bus_message *m,
error:
if (r < 0)
- log_debug("idev-keyboard: cannot parse locale property from locale1: %s", strerror(-r));
+ log_debug_errno(-r, "idev-keyboard: cannot parse locale property from locale1: %m");
return r;
}
@@ -448,7 +448,7 @@ static int kbdctx_query_locale(kbdctx *kc) {
return 0;
error:
- log_debug("idev-keyboard: cannot send GetAll to locale1: %s", strerror(-r));
+ log_debug_errno(-r, "idev-keyboard: cannot send GetAll to locale1: %m");
return r;
}
@@ -480,7 +480,7 @@ static int kbdctx_locale_props_changed_fn(sd_bus *bus,
return 0;
error:
- log_debug("idev-keyboard: cannot handle PropertiesChanged from locale1: %s", strerror(-r));
+ log_debug_errno(-r, "idev-keyboard: cannot handle PropertiesChanged from locale1: %m");
return r;
}
@@ -497,7 +497,7 @@ static int kbdctx_setup_bus(kbdctx *kc) {
kbdctx_locale_props_changed_fn,
kc);
if (r < 0) {
- log_debug("idev-keyboard: cannot setup locale1 link: %s", strerror(-r));
+ log_debug_errno(-r, "idev-keyboard: cannot setup locale1 link: %m");
return r;
}
diff --git a/src/libsystemd-terminal/modeset.c b/src/libsystemd-terminal/modeset.c
index f0508d7a05..9871e306e4 100644
--- a/src/libsystemd-terminal/modeset.c
+++ b/src/libsystemd-terminal/modeset.c
@@ -147,13 +147,13 @@ static int modeset_new(Modeset **out) {
r = sd_pid_get_session(getpid(), &m->session);
if (r < 0) {
- log_error("Cannot retrieve logind session: %s", strerror(-r));
+ log_error_errno(-r, "Cannot retrieve logind session: %m");
return r;
}
r = sd_session_get_seat(m->session, &m->seat);
if (r < 0) {
- log_error("Cannot retrieve seat of logind session: %s", strerror(-r));
+ log_error_errno(-r, "Cannot retrieve seat of logind session: %m");
return r;
}
@@ -310,14 +310,14 @@ static int modeset_sysview_fn(sysview_context *c, void *userdata, sysview_event
modeset_grdev_fn,
m);
if (r < 0) {
- log_error("Cannot create grdev session: %s", strerror(-r));
+ log_error_errno(-r, "Cannot create grdev session: %m");
return r;
}
if (m->managed) {
r = sysview_session_take_control(ev->session_add.session);
if (r < 0) {
- log_error("Cannot request session control: %s", strerror(-r));
+ log_error_errno(-r, "Cannot request session control: %m");
return r;
}
}
@@ -359,7 +359,7 @@ static int modeset_sysview_fn(sysview_context *c, void *userdata, sysview_event
case SYSVIEW_EVENT_SESSION_CONTROL:
r = ev->session_control.error;
if (r < 0) {
- log_error("Cannot acquire session control: %s", strerror(-r));
+ log_error_errno(-r, "Cannot acquire session control: %m");
return r;
}
diff --git a/src/libsystemd-terminal/subterm.c b/src/libsystemd-terminal/subterm.c
index 93c06bea83..ef112d4014 100644
--- a/src/libsystemd-terminal/subterm.c
+++ b/src/libsystemd-terminal/subterm.c
@@ -126,7 +126,7 @@ static int output_flush(Output *o) {
len = loop_write(o->fd, o->obuf, o->n_obuf, false);
if (len < 0) {
- log_error("error: cannot write to TTY (%zd): %s", len, strerror(-len));
+ log_error_errno(-len, "error: cannot write to TTY (%zd): %m", len);
return len;
}
@@ -157,7 +157,7 @@ static int output_write(Output *o, const void *buf, size_t size) {
len = loop_write(o->fd, buf, size, false);
if (len < 0) {
- log_error("error: cannot write to TTY (%zd): %s", len, strerror(-len));
+ log_error_errno(-len, "error: cannot write to TTY (%zd): %m", len);
return len;
}
@@ -612,12 +612,12 @@ static int terminal_winch_fn(sd_event_source *source, const struct signalfd_sigi
if (t->pty) {
r = pty_resize(t->pty, t->output->in_width, t->output->in_height);
if (r < 0)
- log_error("error: pty_resize() (%d): %s", r, strerror(-r));
+ log_error_errno(-r, "error: pty_resize() (%d): %m", r);
}
r = term_screen_resize(t->screen, t->output->in_width, t->output->in_height);
if (r < 0)
- log_error("error: term_screen_resize() (%d): %s", r, strerror(-r));
+ log_error_errno(-r, "error: term_screen_resize() (%d): %m", r);
terminal_dirty(t);
@@ -657,7 +657,7 @@ static int terminal_write_tmp(Terminal *t) {
for (i = 0; i < num; ++i) {
r = pty_write(t->pty, vec[i].iov_base, vec[i].iov_len);
if (r < 0) {
- log_error("error: cannot write to PTY (%d): %s", r, strerror(-r));
+ log_error_errno(-r, "error: cannot write to PTY (%d): %m", r);
return r;
}
}
@@ -726,7 +726,7 @@ static int terminal_io_fn(sd_event_source *source, int fd, uint32_t revents, voi
for (j = 0; j < n_str; ++j) {
type = term_parser_feed(t->parser, &seq, str[j]);
if (type < 0) {
- log_error("error: term_parser_feed() (%d): %s", type, strerror(-type));
+ log_error_errno(-type, "error: term_parser_feed() (%d): %m", type);
return type;
}
@@ -778,7 +778,7 @@ static int terminal_pty_fn(Pty *pty, void *userdata, unsigned int event, const v
case PTY_DATA:
r = term_screen_feed_text(t->screen, ptr, size);
if (r < 0) {
- log_error("error: term_screen_feed_text() (%d): %s", r, strerror(-r));
+ log_error_errno(-r, "error: term_screen_feed_text() (%d): %m", r);
return r;
}
@@ -857,49 +857,49 @@ static int terminal_new(Terminal **out, int in_fd, int out_fd) {
r = tcsetattr(t->in_fd, TCSANOW, &in_attr);
if (r < 0) {
- log_error("error: tcsetattr() (%d): %s", r, strerror(-r));
+ log_error_errno(-r, "error: tcsetattr() (%d): %m", r);
goto error;
}
r = tcsetattr(t->out_fd, TCSANOW, &out_attr);
if (r < 0) {
- log_error("error: tcsetattr() (%d): %s", r, strerror(-r));
+ log_error_errno(-r, "error: tcsetattr() (%d): %m", r);
goto error;
}
r = sd_event_default(&t->event);
if (r < 0) {
- log_error("error: sd_event_default() (%d): %s", r, strerror(-r));
+ log_error_errno(-r, "error: sd_event_default() (%d): %m", r);
goto error;
}
r = sigprocmask_many(SIG_BLOCK, SIGINT, SIGQUIT, SIGTERM, SIGWINCH, SIGCHLD, -1);
if (r < 0) {
- log_error("error: sigprocmask_many() (%d): %s", r, strerror(-r));
+ log_error_errno(-r, "error: sigprocmask_many() (%d): %m", r);
goto error;
}
r = sd_event_add_signal(t->event, NULL, SIGINT, NULL, NULL);
if (r < 0) {
- log_error("error: sd_event_add_signal() (%d): %s", r, strerror(-r));
+ log_error_errno(-r, "error: sd_event_add_signal() (%d): %m", r);
goto error;
}
r = sd_event_add_signal(t->event, NULL, SIGQUIT, NULL, NULL);
if (r < 0) {
- log_error("error: sd_event_add_signal() (%d): %s", r, strerror(-r));
+ log_error_errno(-r, "error: sd_event_add_signal() (%d): %m", r);
goto error;
}
r = sd_event_add_signal(t->event, NULL, SIGTERM, NULL, NULL);
if (r < 0) {
- log_error("error: sd_event_add_signal() (%d): %s", r, strerror(-r));
+ log_error_errno(-r, "error: sd_event_add_signal() (%d): %m", r);
goto error;
}
r = sd_event_add_signal(t->event, NULL, SIGWINCH, terminal_winch_fn, t);
if (r < 0) {
- log_error("error: sd_event_add_signal() (%d): %s", r, strerror(-r));
+ log_error_errno(-r, "error: sd_event_add_signal() (%d): %m", r);
goto error;
}
@@ -907,7 +907,7 @@ static int terminal_new(Terminal **out, int in_fd, int out_fd) {
t->is_dirty = true;
r = sd_event_add_time(t->event, &t->frame_timer, CLOCK_MONOTONIC, 0, 0, terminal_frame_timer_fn, t);
if (r < 0) {
- log_error("error: sd_event_add_time() (%d): %s", r, strerror(-r));
+ log_error_errno(-r, "error: sd_event_add_time() (%d): %m", r);
goto error;
}
@@ -929,7 +929,7 @@ static int terminal_new(Terminal **out, int in_fd, int out_fd) {
r = term_screen_resize(t->screen, t->output->in_width, t->output->in_height);
if (r < 0) {
- log_error("error: term_screen_resize() (%d): %s", r, strerror(-r));
+ log_error_errno(-r, "error: term_screen_resize() (%d): %m", r);
goto error;
}
@@ -952,7 +952,7 @@ static int terminal_run(Terminal *t) {
pid = pty_fork(&t->pty, t->event, terminal_pty_fn, t, t->output->in_width, t->output->in_height);
if (pid < 0) {
- log_error("error: cannot fork PTY (%d): %s", pid, strerror(-pid));
+ log_error_errno(-pid, "error: cannot fork PTY (%d): %m", pid);
return pid;
} else if (pid == 0) {
/* child */
@@ -993,7 +993,7 @@ int main(int argc, char *argv[]) {
out:
if (r < 0)
- log_error("error: terminal failed (%d): %s", r, strerror(-r));
+ log_error_errno(-r, "error: terminal failed (%d): %m", r);
terminal_free(t);
return -r;
}
diff --git a/src/libsystemd-terminal/sysview.c b/src/libsystemd-terminal/sysview.c
index 70a6ca726c..2eab289c41 100644
--- a/src/libsystemd-terminal/sysview.c
+++ b/src/libsystemd-terminal/sysview.c
@@ -1498,7 +1498,7 @@ static int context_scan_fn(sd_event_source *s, void *userdata) {
if (!c->scanned) {
r = context_ld_scan(c);
if (r < 0) {
- log_debug("sysview: logind scan failed: %s", strerror(-r));
+ log_debug_errno(-r, "sysview: logind scan failed: %m");
return r;
}
}
@@ -1507,7 +1507,7 @@ static int context_scan_fn(sd_event_source *s, void *userdata) {
if (hashmap_size(c->session_map) > 0) {
r = context_ud_scan(c);
if (r < 0) {
- log_debug("sysview: udev scan failed: %s", strerror(-r));
+ log_debug_errno(-r, "sysview: udev scan failed: %m");
return r;
}
diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c
index 2ddf016a95..54716bd904 100644
--- a/src/libsystemd/sd-bus/bus-dump.c
+++ b/src/libsystemd/sd-bus/bus-dump.c
@@ -126,7 +126,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
r = sd_bus_message_rewind(m, !(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY));
if (r < 0) {
- log_error("Failed to rewind: %s", strerror(-r));
+ log_error_errno(-r, "Failed to rewind: %m");
return r;
}
@@ -152,7 +152,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
r = sd_bus_message_peek_type(m, &type, &contents);
if (r < 0) {
- log_error("Failed to peek type: %s", strerror(-r));
+ log_error_errno(-r, "Failed to peek type: %m");
return r;
}
@@ -162,7 +162,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
r = sd_bus_message_exit_container(m);
if (r < 0) {
- log_error("Failed to exit container: %s", strerror(-r));
+ log_error_errno(-r, "Failed to exit container: %m");
return r;
}
@@ -183,7 +183,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
if (bus_type_is_container(type) > 0) {
r = sd_bus_message_enter_container(m, type, contents);
if (r < 0) {
- log_error("Failed to enter container: %s", strerror(-r));
+ log_error_errno(-r, "Failed to enter container: %m");
return r;
}
@@ -203,7 +203,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
r = sd_bus_message_read_basic(m, type, &basic);
if (r < 0) {
- log_error("Failed to get basic: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get basic: %m");
return r;
}
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 84fb4bdf2b..fe150ccdae 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -1059,7 +1059,7 @@ int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call
/* Anybody can send us invalid messages, let's just drop them. */
if (r == -EBADMSG || r == -EPROTOTYPE)
- log_debug("Ignoring invalid message: %s", strerror(-r));
+ log_debug_errno(-r, "Ignoring invalid message: %m");
else
return r;
}
@@ -1243,7 +1243,7 @@ int bus_kernel_read_message(sd_bus *bus, bool hint_priority, int64_t priority) {
/* Anybody can send us invalid messages, let's just drop them. */
if (r == -EBADMSG || r == -EPROTOTYPE) {
- log_debug("Ignoring invalid message: %s", strerror(-r));
+ log_debug_errno(-r, "Ignoring invalid message: %m");
r = 0;
}
diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c
index f3b593d2b8..0b2f2a9059 100644
--- a/src/libsystemd/sd-bus/bus-track.c
+++ b/src/libsystemd/sd-bus/bus-track.c
@@ -309,7 +309,7 @@ void bus_track_dispatch(sd_bus_track *track) {
r = track->handler(track, track->userdata);
if (r < 0)
- log_debug("Failed to process track handler: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to process track handler: %m");
else if (r == 0)
bus_track_add_to_queue(track);
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
index 5345526309..4b5c1a6d36 100644
--- a/src/libsystemd/sd-bus/bus-util.c
+++ b/src/libsystemd/sd-bus/bus-util.c
@@ -1263,12 +1263,12 @@ int bus_property_get_ulong(
#endif
int bus_log_parse_error(int r) {
- log_error("Failed to parse bus message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to parse bus message: %m");
return r;
}
int bus_log_create_error(int r) {
- log_error("Failed to create bus message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create bus message: %m");
return r;
}
diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c
index e432db406b..8cc309c01b 100644
--- a/src/libsystemd/sd-bus/busctl.c
+++ b/src/libsystemd/sd-bus/busctl.c
@@ -90,7 +90,7 @@ static int list_bus_names(sd_bus *bus, char **argv) {
r = sd_bus_list_names(bus, (arg_acquired || arg_unique) ? &acquired : NULL, arg_activatable ? &activatable : NULL);
if (r < 0) {
- log_error("Failed to list names: %s", strerror(-r));
+ log_error_errno(-r, "Failed to list names: %m");
return r;
}
@@ -105,7 +105,7 @@ static int list_bus_names(sd_bus *bus, char **argv) {
r = hashmap_put(names, *i, NAME_IS_ACQUIRED);
if (r < 0) {
- log_error("Failed to add to hashmap: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add to hashmap: %m");
return r;
}
}
@@ -115,7 +115,7 @@ static int list_bus_names(sd_bus *bus, char **argv) {
r = hashmap_put(names, *i, NAME_IS_ACTIVATABLE);
if (r < 0 && r != -EEXIST) {
- log_error("Failed to add to hashmap: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add to hashmap: %m");
return r;
}
}
@@ -439,7 +439,7 @@ static int tree(sd_bus *bus, char **argv) {
r = sd_bus_list_names(bus, &names, NULL);
if (r < 0) {
- log_error("Failed to get name list: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get name list: %m");
return r;
}
@@ -1096,7 +1096,7 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL
r = sd_bus_add_match(bus, NULL, m, NULL, NULL);
if (r < 0) {
- log_error("Failed to add match: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match: %m");
return r;
}
@@ -1106,7 +1106,7 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL
STRV_FOREACH(i, arg_matches) {
r = sd_bus_add_match(bus, NULL, *i, NULL, NULL);
if (r < 0) {
- log_error("Failed to add match: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match: %m");
return r;
}
@@ -1116,7 +1116,7 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL
if (!added_something) {
r = sd_bus_add_match(bus, NULL, "", NULL, NULL);
if (r < 0) {
- log_error("Failed to add match: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match: %m");
return r;
}
}
@@ -1126,7 +1126,7 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL
r = sd_bus_process(bus, &m);
if (r < 0) {
- log_error("Failed to process bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to process bus: %m");
return r;
}
@@ -1140,7 +1140,7 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL
r = sd_bus_wait(bus, (uint64_t) -1);
if (r < 0) {
- log_error("Failed to wait for bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to wait for bus: %m");
return r;
}
}
@@ -1200,7 +1200,7 @@ static int status(sd_bus *bus, char *argv[]) {
&creds);
if (r < 0) {
- log_error("Failed to get credentials: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get credentials: %m");
return r;
}
@@ -1962,7 +1962,7 @@ int main(int argc, char *argv[]) {
r = sd_bus_new(&bus);
if (r < 0) {
- log_error("Failed to allocate bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate bus: %m");
goto finish;
}
@@ -1971,25 +1971,25 @@ int main(int argc, char *argv[]) {
r = sd_bus_set_monitor(bus, true);
if (r < 0) {
- log_error("Failed to set monitor mode: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set monitor mode: %m");
goto finish;
}
r = sd_bus_negotiate_creds(bus, true, _SD_BUS_CREDS_ALL);
if (r < 0) {
- log_error("Failed to enable credentials: %s", strerror(-r));
+ log_error_errno(-r, "Failed to enable credentials: %m");
goto finish;
}
r = sd_bus_negotiate_timestamp(bus, true);
if (r < 0) {
- log_error("Failed to enable timestamps: %s", strerror(-r));
+ log_error_errno(-r, "Failed to enable timestamps: %m");
goto finish;
}
r = sd_bus_negotiate_fds(bus, true);
if (r < 0) {
- log_error("Failed to enable fds: %s", strerror(-r));
+ log_error_errno(-r, "Failed to enable fds: %m");
goto finish;
}
}
@@ -1999,7 +1999,7 @@ int main(int argc, char *argv[]) {
else {
r = sd_bus_set_bus_client(bus, true);
if (r < 0) {
- log_error("Failed to set bus client: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set bus client: %m");
goto finish;
}
@@ -2025,13 +2025,13 @@ int main(int argc, char *argv[]) {
}
}
if (r < 0) {
- log_error("Failed to set address: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set address: %m");
goto finish;
}
r = sd_bus_start(bus);
if (r < 0) {
- log_error("Failed to connect to bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to connect to bus: %m");
goto finish;
}
diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c
index 8ee66cfcda..7703878982 100644
--- a/src/libsystemd/sd-bus/test-bus-chat.c
+++ b/src/libsystemd/sd-bus/test-bus-chat.c
@@ -54,7 +54,7 @@ static int object_callback(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bu
r = sd_bus_reply_method_return(m, NULL);
if (r < 0) {
- log_error("Failed to send reply: %s", strerror(-r));
+ log_error_errno(-r, "Failed to send reply: %m");
return r;
}
@@ -74,19 +74,19 @@ static int server_init(sd_bus **_bus) {
r = sd_bus_open_user(&bus);
if (r < 0) {
- log_error("Failed to connect to user bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to connect to user bus: %m");
goto fail;
}
r = sd_bus_get_owner_id(bus, &id);
if (r < 0) {
- log_error("Failed to get server ID: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get server ID: %m");
goto fail;
}
r = sd_bus_get_unique_name(bus, &unique);
if (r < 0) {
- log_error("Failed to get unique name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get unique name: %m");
goto fail;
}
@@ -96,25 +96,25 @@ static int server_init(sd_bus **_bus) {
r = sd_bus_request_name(bus, "org.freedesktop.systemd.test", 0);
if (r < 0) {
- log_error("Failed to acquire name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to acquire name: %m");
goto fail;
}
r = sd_bus_add_fallback(bus, NULL, "/foo/bar", object_callback, NULL);
if (r < 0) {
- log_error("Failed to add object: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add object: %m");
goto fail;
}
r = sd_bus_add_match(bus, NULL, "type='signal',interface='foo.bar',member='Notify'", match_callback, NULL);
if (r < 0) {
- log_error("Failed to add match: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match: %m");
goto fail;
}
r = sd_bus_add_match(bus, NULL, "type='signal',interface='org.freedesktop.DBus',member='NameOwnerChanged'", match_callback, NULL);
if (r < 0) {
- log_error("Failed to add match: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match: %m");
goto fail;
}
@@ -141,14 +141,14 @@ static int server(sd_bus *bus) {
r = sd_bus_process(bus, &m);
if (r < 0) {
- log_error("Failed to process requests: %s", strerror(-r));
+ log_error_errno(-r, "Failed to process requests: %m");
goto fail;
}
if (r == 0) {
r = sd_bus_wait(bus, (uint64_t) -1);
if (r < 0) {
- log_error("Failed to wait: %s", strerror(-r));
+ log_error_errno(-r, "Failed to wait: %m");
goto fail;
}
@@ -173,7 +173,7 @@ static int server(sd_bus *bus) {
r = sd_bus_message_read(m, "s", &hello);
if (r < 0) {
- log_error("Failed to get parameter: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get parameter: %m");
goto fail;
}
@@ -187,14 +187,14 @@ static int server(sd_bus *bus) {
r = sd_bus_reply_method_return(m, "s", lowercase);
if (r < 0) {
- log_error("Failed to send reply: %s", strerror(-r));
+ log_error_errno(-r, "Failed to send reply: %m");
goto fail;
}
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.systemd.test", "ExitClient1")) {
r = sd_bus_reply_method_return(m, NULL);
if (r < 0) {
- log_error("Failed to send reply: %s", strerror(-r));
+ log_error_errno(-r, "Failed to send reply: %m");
goto fail;
}
@@ -203,7 +203,7 @@ static int server(sd_bus *bus) {
r = sd_bus_reply_method_return(m, NULL);
if (r < 0) {
- log_error("Failed to send reply: %s", strerror(-r));
+ log_error_errno(-r, "Failed to send reply: %m");
goto fail;
}
@@ -214,7 +214,7 @@ static int server(sd_bus *bus) {
r = sd_bus_reply_method_return(m, NULL);
if (r < 0) {
- log_error("Failed to send reply: %s", strerror(-r));
+ log_error_errno(-r, "Failed to send reply: %m");
goto fail;
}
@@ -224,7 +224,7 @@ static int server(sd_bus *bus) {
r = sd_bus_message_read(m, "h", &fd);
if (r < 0) {
- log_error("Failed to get parameter: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get parameter: %m");
goto fail;
}
@@ -238,7 +238,7 @@ static int server(sd_bus *bus) {
r = sd_bus_reply_method_return(m, NULL);
if (r < 0) {
- log_error("Failed to send reply: %s", strerror(-r));
+ log_error_errno(-r, "Failed to send reply: %m");
goto fail;
}
@@ -248,7 +248,7 @@ static int server(sd_bus *bus) {
m,
&SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_UNKNOWN_METHOD, "Unknown method."));
if (r < 0) {
- log_error("Failed to send reply: %s", strerror(-r));
+ log_error_errno(-r, "Failed to send reply: %m");
goto fail;
}
}
@@ -276,7 +276,7 @@ static void* client1(void*p) {
r = sd_bus_open_user(&bus);
if (r < 0) {
- log_error("Failed to connect to user bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to connect to user bus: %m");
goto finish;
}
@@ -291,13 +291,13 @@ static void* client1(void*p) {
"s",
"HELLO");
if (r < 0) {
- log_error("Failed to issue method call: %s", strerror(-r));
+ log_error_errno(-r, "Failed to issue method call: %m");
goto finish;
}
r = sd_bus_message_read(reply, "s", &hello);
if (r < 0) {
- log_error("Failed to get string: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get string: %m");
goto finish;
}
@@ -322,7 +322,7 @@ static void* client1(void*p) {
"h",
pp[1]);
if (r < 0) {
- log_error("Failed to issue method call: %s", strerror(-r));
+ log_error_errno(-r, "Failed to issue method call: %m");
goto finish;
}
@@ -346,7 +346,7 @@ finish:
"org.freedesktop.systemd.test",
"ExitClient1");
if (r < 0)
- log_error("Failed to allocate method call: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate method call: %m");
else
sd_bus_send(bus, q, NULL);
@@ -380,7 +380,7 @@ static void* client2(void*p) {
r = sd_bus_open_user(&bus);
if (r < 0) {
- log_error("Failed to connect to user bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to connect to user bus: %m");
goto finish;
}
@@ -392,7 +392,7 @@ static void* client2(void*p) {
"org.object.test",
"Foobar");
if (r < 0) {
- log_error("Failed to allocate method call: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate method call: %m");
goto finish;
}
@@ -412,7 +412,7 @@ static void* client2(void*p) {
"foo.bar",
"Notify");
if (r < 0) {
- log_error("Failed to allocate signal: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate signal: %m");
goto finish;
}
@@ -433,7 +433,7 @@ static void* client2(void*p) {
"org.freedesktop.DBus.Peer",
"GetMachineId");
if (r < 0) {
- log_error("Failed to allocate method call: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate method call: %m");
goto finish;
}
@@ -445,7 +445,7 @@ static void* client2(void*p) {
r = sd_bus_message_read(reply, "s", &mid);
if (r < 0) {
- log_error("Failed to parse machine ID: %s", strerror(-r));
+ log_error_errno(-r, "Failed to parse machine ID: %m");
goto finish;
}
@@ -462,7 +462,7 @@ static void* client2(void*p) {
"org.freedesktop.systemd.test",
"Slow");
if (r < 0) {
- log_error("Failed to allocate method call: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate method call: %m");
goto finish;
}
@@ -486,7 +486,7 @@ static void* client2(void*p) {
"org.freedesktop.systemd.test",
"Slow");
if (r < 0) {
- log_error("Failed to allocate method call: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate method call: %m");
goto finish;
}
@@ -499,13 +499,13 @@ static void* client2(void*p) {
while (!quit) {
r = sd_bus_process(bus, NULL);
if (r < 0) {
- log_error("Failed to process requests: %s", strerror(-r));
+ log_error_errno(-r, "Failed to process requests: %m");
goto finish;
}
if (r == 0) {
r = sd_bus_wait(bus, (uint64_t) -1);
if (r < 0) {
- log_error("Failed to wait: %s", strerror(-r));
+ log_error_errno(-r, "Failed to wait: %m");
goto finish;
}
}
@@ -525,7 +525,7 @@ finish:
"org.freedesktop.systemd.test",
"ExitClient2");
if (r < 0) {
- log_error("Failed to allocate method call: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate method call: %m");
goto finish;
}
diff --git a/src/libsystemd/sd-bus/test-bus-objects.c b/src/libsystemd/sd-bus/test-bus-objects.c
index 1324e912fc..2ed34e5120 100644
--- a/src/libsystemd/sd-bus/test-bus-objects.c
+++ b/src/libsystemd/sd-bus/test-bus-objects.c
@@ -237,14 +237,14 @@ static void *server(void *p) {
r = sd_bus_process(bus, NULL);
if (r < 0) {
- log_error("Failed to process requests: %s", strerror(-r));
+ log_error_errno(-r, "Failed to process requests: %m");
goto fail;
}
if (r == 0) {
r = sd_bus_wait(bus, (uint64_t) -1);
if (r < 0) {
- log_error("Failed to wait: %s", strerror(-r));
+ log_error_errno(-r, "Failed to wait: %m");
goto fail;
}
diff --git a/src/libsystemd/sd-bus/test-bus-server.c b/src/libsystemd/sd-bus/test-bus-server.c
index 96d6298336..30e2d8cf44 100644
--- a/src/libsystemd/sd-bus/test-bus-server.c
+++ b/src/libsystemd/sd-bus/test-bus-server.c
@@ -65,14 +65,14 @@ static void *server(void *p) {
r = sd_bus_process(bus, &m);
if (r < 0) {
- log_error("Failed to process requests: %s", strerror(-r));
+ log_error_errno(-r, "Failed to process requests: %m");
goto fail;
}
if (r == 0) {
r = sd_bus_wait(bus, (uint64_t) -1);
if (r < 0) {
- log_error("Failed to wait: %s", strerror(-r));
+ log_error_errno(-r, "Failed to wait: %m");
goto fail;
}
@@ -90,7 +90,7 @@ static void *server(void *p) {
r = sd_bus_message_new_method_return(m, &reply);
if (r < 0) {
- log_error("Failed to allocate return: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate return: %m");
goto fail;
}
@@ -102,7 +102,7 @@ static void *server(void *p) {
&reply,
&SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_UNKNOWN_METHOD, "Unknown method."));
if (r < 0) {
- log_error("Failed to allocate return: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate return: %m");
goto fail;
}
}
@@ -110,7 +110,7 @@ static void *server(void *p) {
if (reply) {
r = sd_bus_send(bus, reply, NULL);
if (r < 0) {
- log_error("Failed to send reply: %s", strerror(-r));
+ log_error_errno(-r, "Failed to send reply: %m");
goto fail;
}
}
@@ -147,7 +147,7 @@ static int client(struct context *c) {
"org.freedesktop.systemd.test",
"Exit");
if (r < 0) {
- log_error("Failed to allocate method call: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate method call: %m");
return r;
}
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index fb436adc13..993ef202de 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -2158,9 +2158,9 @@ static int source_dispatch(sd_event_source *s) {
if (r < 0) {
if (s->description)
- log_debug("Event source '%s' returned error, disabling: %s", s->description, strerror(-r));
+ log_debug_errno(-r, "Event source '%s' returned error, disabling: %m", s->description);
else
- log_debug("Event source %p returned error, disabling: %s", s, strerror(-r));
+ log_debug_errno(-r, "Event source %p returned error, disabling: %m", s);
}
if (s->n_ref == 0)
@@ -2196,9 +2196,9 @@ static int event_prepare(sd_event *e) {
if (r < 0) {
if (s->description)
- log_debug("Prepare callback of event source '%s' returned error, disabling: %s", s->description, strerror(-r));
+ log_debug_errno(-r, "Prepare callback of event source '%s' returned error, disabling: %m", s->description);
else
- log_debug("Prepare callback of event source %p returned error, disabling: %s", s, strerror(-r));
+ log_debug_errno(-r, "Prepare callback of event source %p returned error, disabling: %m", s);
}
if (s->n_ref == 0)
diff --git a/src/libsystemd/sd-rtnl/rtnl-util.c b/src/libsystemd/sd-rtnl/rtnl-util.c
index 1ec1fa8d27..1adfbb8643 100644
--- a/src/libsystemd/sd-rtnl/rtnl-util.c
+++ b/src/libsystemd/sd-rtnl/rtnl-util.c
@@ -157,11 +157,11 @@ bool rtnl_message_type_is_addr(uint16_t type) {
}
int rtnl_log_parse_error(int r) {
- log_error("Failed to parse netlink message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to parse netlink message: %m");
return r;
}
int rtnl_log_create_error(int r) {
- log_error("Failed to create netlink message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create netlink message: %m");
return r;
}
diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c
index 46b5bb20c3..d77bce45cc 100644
--- a/src/libsystemd/sd-rtnl/test-rtnl.c
+++ b/src/libsystemd/sd-rtnl/test-rtnl.c
@@ -135,7 +135,7 @@ static void test_route(void) {
r = sd_rtnl_message_new_route(NULL, &req, RTM_NEWROUTE, AF_INET, RTPROT_STATIC);
if (r < 0) {
- log_error("Could not create RTM_NEWROUTE message: %s", strerror(-r));
+ log_error_errno(-r, "Could not create RTM_NEWROUTE message: %m");
return;
}
@@ -143,13 +143,13 @@ static void test_route(void) {
r = sd_rtnl_message_append_in_addr(req, RTA_GATEWAY, &addr);
if (r < 0) {
- log_error("Could not append RTA_GATEWAY attribute: %s", strerror(-r));
+ log_error_errno(-r, "Could not append RTA_GATEWAY attribute: %m");
return;
}
r = sd_rtnl_message_append_u32(req, RTA_OIF, index);
if (r < 0) {
- log_error("Could not append RTA_OIF attribute: %s", strerror(-r));
+ log_error_errno(-r, "Could not append RTA_OIF attribute: %m");
return;
}
@@ -223,7 +223,7 @@ static int pipe_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
- log_info("%d left in pipe. got reply: %s", *counter, strerror(-r));
+ log_info_errno(-r, "%d left in pipe. got reply: %m", *counter);
assert_se(r >= 0);
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index d4a2d29aea..70f3b56558 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -110,7 +110,7 @@ static void print_overriden_variables(void) {
NULL);
if (r < 0 && r != -ENOENT) {
- log_warning("Failed to read /proc/cmdline: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to read /proc/cmdline: %m");
goto finish;
}
@@ -178,7 +178,7 @@ static int show_status(sd_bus *bus, char **args, unsigned n) {
map,
&info);
if (r < 0) {
- log_error("Could not get properties: %s", strerror(-r));
+ log_error_errno(-r, "Could not get properties: %m");
goto fail;
}
@@ -235,7 +235,7 @@ static int list_locales(sd_bus *bus, char **args, unsigned n) {
r = get_locales(&l);
if (r < 0) {
- log_error("Failed to read list of locales: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read list of locales: %m");
return r;
}
@@ -310,7 +310,7 @@ static int nftw_cb(
r = set_consume(keymaps, p);
if (r < 0 && r != -EEXIST) {
- log_error("Can't add keymap: %s", strerror(-r));
+ log_error_errno(-r, "Can't add keymap: %m");
return r;
}
@@ -683,7 +683,7 @@ int main(int argc, char*argv[]) {
r = bus_open_transport(arg_transport, arg_host, false, &bus);
if (r < 0) {
- log_error("Failed to create bus connection: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create bus connection: %m");
goto finish;
}
diff --git a/src/locale/localed.c b/src/locale/localed.c
index 7fe73247d4..2a293a7bc0 100644
--- a/src/locale/localed.c
+++ b/src/locale/localed.c
@@ -375,7 +375,7 @@ static int locale_update_system_manager(Context *c, sd_bus *bus) {
r = sd_bus_call(bus, m, 0, &error, NULL);
if (r < 0)
- log_error("Failed to update the manager environment: %s", strerror(-r));
+ log_error_errno(-r, "Failed to update the manager environment: %m");
return 0;
}
@@ -611,7 +611,7 @@ static int vconsole_convert_to_x11(Context *c, sd_bus *bus) {
r = x11_write_data(c);
if (r < 0) {
- log_error("Failed to set X11 keyboard layout: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set X11 keyboard layout: %m");
return r;
}
@@ -790,7 +790,7 @@ static int x11_convert_to_vconsole(Context *c, sd_bus *bus) {
if (modified) {
r = vconsole_write_data(c);
if (r < 0)
- log_error("Failed to set virtual console keymap: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set virtual console keymap: %m");
log_info("Changed virtual console keymap to '%s' toggle '%s'",
strempty(c->vc_keymap), strempty(c->vc_keymap_toggle));
@@ -923,7 +923,7 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata, sd_
r = locale_write_data(c, &settings);
if (r < 0) {
- log_error("Failed to set locale: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set locale: %m");
return sd_bus_error_set_errnof(error, r, "Failed to set locale: %s", strerror(-r));
}
@@ -983,7 +983,7 @@ static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata
r = vconsole_write_data(c);
if (r < 0) {
- log_error("Failed to set virtual console keymap: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set virtual console keymap: %m");
return sd_bus_error_set_errnof(error, r, "Failed to set virtual console keymap: %s", strerror(-r));
}
@@ -992,7 +992,7 @@ static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata
r = vconsole_reload(bus);
if (r < 0)
- log_error("Failed to request keymap reload: %s", strerror(-r));
+ log_error_errno(-r, "Failed to request keymap reload: %m");
sd_bus_emit_properties_changed(bus,
"/org/freedesktop/locale1",
@@ -1002,7 +1002,7 @@ static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata
if (convert) {
r = vconsole_convert_to_x11(c, bus);
if (r < 0)
- log_error("Failed to convert keymap data: %s", strerror(-r));
+ log_error_errno(-r, "Failed to convert keymap data: %m");
}
}
@@ -1106,7 +1106,7 @@ static int method_set_x11_keyboard(sd_bus *bus, sd_bus_message *m, void *userdat
r = x11_write_data(c);
if (r < 0) {
- log_error("Failed to set X11 keyboard layout: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set X11 keyboard layout: %m");
return sd_bus_error_set_errnof(error, r, "Failed to set X11 keyboard layout: %s", strerror(-r));
}
@@ -1124,7 +1124,7 @@ static int method_set_x11_keyboard(sd_bus *bus, sd_bus_message *m, void *userdat
if (convert) {
r = x11_convert_to_vconsole(c, bus);
if (r < 0)
- log_error("Failed to convert keymap data: %s", strerror(-r));
+ log_error_errno(-r, "Failed to convert keymap data: %m");
}
}
@@ -1156,25 +1156,25 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
r = sd_bus_default_system(&bus);
if (r < 0) {
- log_error("Failed to get system bus connection: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get system bus connection: %m");
return r;
}
r = sd_bus_add_object_vtable(bus, NULL, "/org/freedesktop/locale1", "org.freedesktop.locale1", locale_vtable, c);
if (r < 0) {
- log_error("Failed to register object: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register object: %m");
return r;
}
r = sd_bus_request_name(bus, "org.freedesktop.locale1", 0);
if (r < 0) {
- log_error("Failed to register name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register name: %m");
return r;
}
r = sd_bus_attach_event(bus, event, 0);
if (r < 0) {
- log_error("Failed to attach bus to event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to attach bus to event loop: %m");
return r;
}
@@ -1205,7 +1205,7 @@ int main(int argc, char *argv[]) {
r = sd_event_default(&event);
if (r < 0) {
- log_error("Failed to allocate event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate event loop: %m");
goto finish;
}
@@ -1217,13 +1217,13 @@ int main(int argc, char *argv[]) {
r = context_read_data(&context);
if (r < 0) {
- log_error("Failed to read locale data: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read locale data: %m");
goto finish;
}
r = bus_event_loop_with_idle(event, bus, "org.freedesktop.locale1", DEFAULT_EXIT_USEC, NULL, NULL);
if (r < 0) {
- log_error("Failed to run event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to run event loop: %m");
goto finish;
}
diff --git a/src/login/inhibit.c b/src/login/inhibit.c
index 8c9d1165d2..3034e20f0e 100644
--- a/src/login/inhibit.c
+++ b/src/login/inhibit.c
@@ -235,7 +235,7 @@ int main(int argc, char *argv[]) {
r = sd_bus_default_system(&bus);
if (r < 0) {
- log_error("Failed to connect to bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to connect to bus: %m");
return EXIT_FAILURE;
}
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index fcdf6275e9..d0fd14b90d 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -385,7 +385,7 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li
r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &i);
if (r < 0) {
- log_error("Could not get properties: %s", strerror(-r));
+ log_error_errno(-r, "Could not get properties: %m");
return r;
}
@@ -498,7 +498,7 @@ static int print_user_status_info(sd_bus *bus, const char *path, bool *new_line)
r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &i);
if (r < 0) {
- log_error("Could not get properties: %s", strerror(-r));
+ log_error_errno(-r, "Could not get properties: %m");
goto finish;
}
@@ -562,7 +562,7 @@ static int print_seat_status_info(sd_bus *bus, const char *path, bool *new_line)
r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &i);
if (r < 0) {
- log_error("Could not get properties: %s", strerror(-r));
+ log_error_errno(-r, "Could not get properties: %m");
goto finish;
}
@@ -617,7 +617,7 @@ static int show_properties(sd_bus *bus, const char *path, bool *new_line) {
r = bus_print_all_properties(bus, "org.freedesktop.login1", path, arg_property, arg_all);
if (r < 0)
- log_error("Could not get properties: %s", strerror(-r));
+ log_error_errno(-r, "Could not get properties: %m");
return r;
}
@@ -700,7 +700,7 @@ static int show_user(sd_bus *bus, char **args, unsigned n) {
r = get_user_creds((const char**) (args+i), &uid, NULL, NULL, NULL);
if (r < 0) {
- log_error("Failed to look up user %s: %s", args[i], strerror(-r));
+ log_error_errno(-r, "Failed to look up user %s: %m", args[i]);
return r;
}
@@ -860,7 +860,7 @@ static int enable_linger(sd_bus *bus, char **args, unsigned n) {
r = get_user_creds((const char**) (args+i), &uid, NULL, NULL, NULL);
if (r < 0) {
- log_error("Failed to look up user %s: %s", args[i], strerror(-r));
+ log_error_errno(-r, "Failed to look up user %s: %m", args[i]);
return r;
}
@@ -893,7 +893,7 @@ static int terminate_user(sd_bus *bus, char **args, unsigned n) {
r = get_user_creds((const char**) (args+i), &uid, NULL, NULL, NULL);
if (r < 0) {
- log_error("Failed to look up user %s: %s", args[i], strerror(-r));
+ log_error_errno(-r, "Failed to look up user %s: %m", args[i]);
return r;
}
@@ -929,7 +929,7 @@ static int kill_user(sd_bus *bus, char **args, unsigned n) {
r = get_user_creds((const char**) (args+i), &uid, NULL, NULL, NULL);
if (r < 0) {
- log_error("Failed to look up user %s: %s", args[i], strerror(-r));
+ log_error_errno(-r, "Failed to look up user %s: %m", args[i]);
return r;
}
@@ -1308,7 +1308,7 @@ int main(int argc, char *argv[]) {
r = bus_open_transport(arg_transport, arg_host, false, &bus);
if (r < 0) {
- log_error("Failed to create bus connection: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create bus connection: %m");
goto finish;
}
diff --git a/src/login/logind-button.c b/src/login/logind-button.c
index e380dc0611..d2cc430845 100644
--- a/src/login/logind-button.c
+++ b/src/login/logind-button.c
@@ -263,7 +263,7 @@ int button_open(Button *b) {
r = sd_event_add_io(b->manager->event, &b->io_event_source, b->fd, EPOLLIN, button_dispatch, b);
if (r < 0) {
- log_error("Failed to add button event: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add button event: %m");
goto fail;
}
diff --git a/src/login/logind-core.c b/src/login/logind-core.c
index ed7ea5da31..0f4ac9fb81 100644
--- a/src/login/logind-core.c
+++ b/src/login/logind-core.c
@@ -551,7 +551,7 @@ bool manager_is_docked_or_multiple_displays(Manager *m) {
* assume that we are docked. */
n = manager_count_displays(m);
if (n < 0)
- log_warning("Display counting failed: %s", strerror(-n));
+ log_warning_errno(-n, "Display counting failed: %m");
else if (n > 1) {
log_debug("Multiple (%i) displays connected.", n);
return true;
diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c
index a9e14af8db..198e7df78c 100644
--- a/src/login/logind-inhibit.c
+++ b/src/login/logind-inhibit.c
@@ -138,7 +138,7 @@ int inhibitor_save(Inhibitor *i) {
finish:
if (r < 0)
- log_error("Failed to save inhibit data %s: %s", i->state_file, strerror(-r));
+ log_error_errno(-r, "Failed to save inhibit data %s: %m", i->state_file);
return r;
}
diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c
index 709c6385e6..04909a991a 100644
--- a/src/login/logind-seat.c
+++ b/src/login/logind-seat.c
@@ -154,7 +154,7 @@ int seat_save(Seat *s) {
finish:
if (r < 0)
- log_error("Failed to save seat data %s: %s", s->state_file, strerror(-r));
+ log_error_errno(-r, "Failed to save seat data %s: %m", s->state_file);
return r;
}
@@ -201,7 +201,7 @@ int seat_preallocate_vts(Seat *s) {
q = vt_allocate(i);
if (q < 0) {
- log_error("Failed to preallocate VT %i: %s", i, strerror(-q));
+ log_error_errno(-q, "Failed to preallocate VT %i: %m", i);
r = q;
}
}
@@ -221,7 +221,7 @@ int seat_apply_acls(Seat *s, Session *old_active) {
!!s->active, s->active ? s->active->user->uid : 0);
if (r < 0)
- log_error("Failed to apply ACLs: %s", strerror(-r));
+ log_error_errno(-r, "Failed to apply ACLs: %m");
return r;
}
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index c4fe53bc61..1cbb64c438 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -292,7 +292,7 @@ int session_save(Session *s) {
finish:
if (r < 0)
- log_error("Failed to save session data %s: %s", s->state_file, strerror(-r));
+ log_error_errno(-r, "Failed to save session data %s: %m", s->state_file);
return r;
}
@@ -338,7 +338,7 @@ int session_load(Session *s) {
NULL);
if (r < 0) {
- log_error("Failed to read %s: %s", s->state_file, strerror(-r));
+ log_error_errno(-r, "Failed to read %s: %m", s->state_file);
return r;
}
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index 1205b48abb..7a39140d88 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -252,7 +252,7 @@ int user_save(User *u) {
finish:
if (r < 0)
- log_error("Failed to save user data %s: %s", u->state_file, strerror(-r));
+ log_error_errno(-r, "Failed to save user data %s: %m", u->state_file);
return r;
}
@@ -278,7 +278,7 @@ int user_load(User *u) {
if (r == -ENOENT)
return 0;
- log_error("Failed to read %s: %s", u->state_file, strerror(-r));
+ log_error_errno(-r, "Failed to read %s: %m", u->state_file);
return r;
}
@@ -311,7 +311,7 @@ static int user_mkdir_runtime_path(User *u) {
r = mkdir_safe_label("/run/user", 0755, 0, 0);
if (r < 0) {
- log_error("Failed to create /run/user: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create /run/user: %m");
return r;
}
@@ -338,7 +338,7 @@ static int user_mkdir_runtime_path(User *u) {
r = mount("tmpfs", p, "tmpfs", MS_NODEV|MS_NOSUID, t);
if (r < 0) {
- log_error("Failed to mount per-user tmpfs directory %s: %s", p, strerror(-r));
+ log_error_errno(-r, "Failed to mount per-user tmpfs directory %s: %m", p);
goto fail;
}
}
@@ -510,14 +510,14 @@ static int user_remove_runtime_path(User *u) {
r = rm_rf(u->runtime_path, false, false, false);
if (r < 0)
- log_error("Failed to remove runtime directory %s: %s", u->runtime_path, strerror(-r));
+ log_error_errno(-r, "Failed to remove runtime directory %s: %m", u->runtime_path);
if (umount2(u->runtime_path, MNT_DETACH) < 0)
log_error("Failed to unmount user runtime directory %s: %m", u->runtime_path);
r = rm_rf(u->runtime_path, false, true, false);
if (r < 0)
- log_error("Failed to remove runtime directory %s: %s", u->runtime_path, strerror(-r));
+ log_error_errno(-r, "Failed to remove runtime directory %s: %m", u->runtime_path);
free(u->runtime_path);
u->runtime_path = NULL;
diff --git a/src/login/logind.c b/src/login/logind.c
index 69b219d89e..63e07ad9a3 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -339,7 +339,7 @@ static int manager_enumerate_linger_users(Manager *m) {
k = manager_add_user_by_name(m, de->d_name, NULL);
if (k < 0) {
- log_notice("Couldn't add lingering user %s: %s", de->d_name, strerror(-k));
+ log_notice_errno(-k, "Couldn't add lingering user %s: %m", de->d_name);
r = k;
}
}
@@ -375,7 +375,7 @@ static int manager_enumerate_users(Manager *m) {
k = manager_add_user_by_name(m, de->d_name, &u);
if (k < 0) {
- log_error("Failed to add user by file name %s: %s", de->d_name, strerror(-k));
+ log_error_errno(-k, "Failed to add user by file name %s: %m", de->d_name);
r = k;
continue;
@@ -423,7 +423,7 @@ static int manager_enumerate_sessions(Manager *m) {
k = manager_add_session(m, de->d_name, &s);
if (k < 0) {
- log_error("Failed to add session by file name %s: %s", de->d_name, strerror(-k));
+ log_error_errno(-k, "Failed to add session by file name %s: %m", de->d_name);
r = k;
continue;
@@ -464,7 +464,7 @@ static int manager_enumerate_inhibitors(Manager *m) {
k = manager_add_inhibitor(m, de->d_name, &i);
if (k < 0) {
- log_notice("Couldn't add inhibitor %s: %s", de->d_name, strerror(-k));
+ log_notice_errno(-k, "Couldn't add inhibitor %s: %m", de->d_name);
r = k;
continue;
}
@@ -584,49 +584,49 @@ static int manager_connect_bus(Manager *m) {
r = sd_bus_default_system(&m->bus);
if (r < 0) {
- log_error("Failed to connect to system bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to connect to system bus: %m");
return r;
}
r = sd_bus_add_object_vtable(m->bus, NULL, "/org/freedesktop/login1", "org.freedesktop.login1.Manager", manager_vtable, m);
if (r < 0) {
- log_error("Failed to add manager object vtable: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add manager object vtable: %m");
return r;
}
r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/login1/seat", "org.freedesktop.login1.Seat", seat_vtable, seat_object_find, m);
if (r < 0) {
- log_error("Failed to add seat object vtable: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add seat object vtable: %m");
return r;
}
r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/login1/seat", seat_node_enumerator, m);
if (r < 0) {
- log_error("Failed to add seat enumerator: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add seat enumerator: %m");
return r;
}
r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/login1/session", "org.freedesktop.login1.Session", session_vtable, session_object_find, m);
if (r < 0) {
- log_error("Failed to add session object vtable: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add session object vtable: %m");
return r;
}
r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/login1/session", session_node_enumerator, m);
if (r < 0) {
- log_error("Failed to add session enumerator: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add session enumerator: %m");
return r;
}
r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/login1/user", "org.freedesktop.login1.User", user_vtable, user_object_find, m);
if (r < 0) {
- log_error("Failed to add user object vtable: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add user object vtable: %m");
return r;
}
r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/login1/user", user_node_enumerator, m);
if (r < 0) {
- log_error("Failed to add user enumerator: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add user enumerator: %m");
return r;
}
@@ -639,7 +639,7 @@ static int manager_connect_bus(Manager *m) {
"path='/org/freedesktop/DBus'",
match_name_owner_changed, m);
if (r < 0) {
- log_error("Failed to add match for NameOwnerChanged: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match for NameOwnerChanged: %m");
return r;
}
@@ -652,7 +652,7 @@ static int manager_connect_bus(Manager *m) {
"path='/org/freedesktop/systemd1'",
match_job_removed, m);
if (r < 0) {
- log_error("Failed to add match for JobRemoved: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match for JobRemoved: %m");
return r;
}
@@ -665,7 +665,7 @@ static int manager_connect_bus(Manager *m) {
"path='/org/freedesktop/systemd1'",
match_unit_removed, m);
if (r < 0) {
- log_error("Failed to add match for UnitRemoved: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match for UnitRemoved: %m");
return r;
}
@@ -677,7 +677,7 @@ static int manager_connect_bus(Manager *m) {
"member='PropertiesChanged'",
match_properties_changed, m);
if (r < 0) {
- log_error("Failed to add match for PropertiesChanged: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match for PropertiesChanged: %m");
return r;
}
@@ -690,7 +690,7 @@ static int manager_connect_bus(Manager *m) {
"path='/org/freedesktop/systemd1'",
match_reloading, m);
if (r < 0) {
- log_error("Failed to add match for Reloading: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match for Reloading: %m");
return r;
}
@@ -709,13 +709,13 @@ static int manager_connect_bus(Manager *m) {
r = sd_bus_request_name(m->bus, "org.freedesktop.login1", 0);
if (r < 0) {
- log_error("Failed to register name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register name: %m");
return r;
}
r = sd_bus_attach_event(m->bus, m->event, 0);
if (r < 0) {
- log_error("Failed to attach bus to event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to attach bus to event loop: %m");
return r;
}
@@ -807,13 +807,13 @@ static int manager_connect_console(Manager *m) {
r = ignore_signals(SIGRTMIN + 1, -1);
if (r < 0) {
- log_error("Cannot ignore SIGRTMIN + 1: %s", strerror(-r));
+ log_error_errno(-r, "Cannot ignore SIGRTMIN + 1: %m");
return r;
}
r = sigprocmask_many(SIG_BLOCK, SIGRTMIN, -1);
if (r < 0) {
- log_error("Cannot block SIGRTMIN: %s", strerror(-r));
+ log_error_errno(-r, "Cannot block SIGRTMIN: %m");
return r;
}
@@ -1017,25 +1017,25 @@ static int manager_dispatch_idle_action(sd_event_source *s, uint64_t t, void *us
elapse, USEC_PER_SEC*30,
manager_dispatch_idle_action, m);
if (r < 0) {
- log_error("Failed to add idle event source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add idle event source: %m");
return r;
}
r = sd_event_source_set_priority(m->idle_action_event_source, SD_EVENT_PRIORITY_IDLE+10);
if (r < 0) {
- log_error("Failed to set idle event source priority: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set idle event source priority: %m");
return r;
}
} else {
r = sd_event_source_set_time(m->idle_action_event_source, elapse);
if (r < 0) {
- log_error("Failed to set idle event timer: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set idle event timer: %m");
return r;
}
r = sd_event_source_set_enabled(m->idle_action_event_source, SD_EVENT_ONESHOT);
if (r < 0) {
- log_error("Failed to enable idle event timer: %s", strerror(-r));
+ log_error_errno(-r, "Failed to enable idle event timer: %m");
return r;
}
}
@@ -1062,7 +1062,7 @@ int manager_startup(Manager *m) {
/* Connect to udev */
r = manager_connect_udev(m);
if (r < 0) {
- log_error("Failed to create udev watchers: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create udev watchers: %m");
return r;
}
@@ -1074,38 +1074,38 @@ int manager_startup(Manager *m) {
/* Instantiate magic seat 0 */
r = manager_add_seat(m, "seat0", &m->seat0);
if (r < 0) {
- log_error("Failed to add seat0: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add seat0: %m");
return r;
}
r = manager_set_lid_switch_ignore(m, 0 + IGNORE_LID_SWITCH_STARTUP_USEC);
if (r < 0)
- log_warning("Failed to set up lid switch ignore event source: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to set up lid switch ignore event source: %m");
/* Deserialize state */
r = manager_enumerate_devices(m);
if (r < 0)
- log_warning("Device enumeration failed: %s", strerror(-r));
+ log_warning_errno(-r, "Device enumeration failed: %m");
r = manager_enumerate_seats(m);
if (r < 0)
- log_warning("Seat enumeration failed: %s", strerror(-r));
+ log_warning_errno(-r, "Seat enumeration failed: %m");
r = manager_enumerate_users(m);
if (r < 0)
- log_warning("User enumeration failed: %s", strerror(-r));
+ log_warning_errno(-r, "User enumeration failed: %m");
r = manager_enumerate_sessions(m);
if (r < 0)
- log_warning("Session enumeration failed: %s", strerror(-r));
+ log_warning_errno(-r, "Session enumeration failed: %m");
r = manager_enumerate_inhibitors(m);
if (r < 0)
- log_warning("Inhibitor enumeration failed: %s", strerror(-r));
+ log_warning_errno(-r, "Inhibitor enumeration failed: %m");
r = manager_enumerate_buttons(m);
if (r < 0)
- log_warning("Button enumeration failed: %s", strerror(-r));
+ log_warning_errno(-r, "Button enumeration failed: %m");
/* Remove stale objects before we start them */
manager_gc(m, false);
@@ -1214,7 +1214,7 @@ int main(int argc, char *argv[]) {
r = manager_startup(m);
if (r < 0) {
- log_error("Failed to fully start up daemon: %s", strerror(-r));
+ log_error_errno(-r, "Failed to fully start up daemon: %m");
goto finish;
}
diff --git a/src/login/user-sessions.c b/src/login/user-sessions.c
index ca5de41f40..3639a1836b 100644
--- a/src/login/user-sessions.c
+++ b/src/login/user-sessions.c
@@ -68,7 +68,7 @@ int main(int argc, char*argv[]) {
r = write_string_file_atomic("/run/nologin", "System is going down.");
if (r < 0) {
- log_error("Failed to create /run/nologin: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create /run/nologin: %m");
return EXIT_FAILURE;
}
diff --git a/src/machine/machine.c b/src/machine/machine.c
index a6d636ea49..88c10b7315 100644
--- a/src/machine/machine.c
+++ b/src/machine/machine.c
@@ -216,7 +216,7 @@ finish:
if (temp_path)
unlink(temp_path);
- log_error("Failed to save machine data %s: %s", m->state_file, strerror(-r));
+ log_error_errno(-r, "Failed to save machine data %s: %m", m->state_file);
}
return r;
@@ -259,7 +259,7 @@ int machine_load(Machine *m) {
if (r == -ENOENT)
return 0;
- log_error("Failed to read %s: %s", m->state_file, strerror(-r));
+ log_error_errno(-r, "Failed to read %s: %m", m->state_file);
return r;
}
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index bbcc2df4cd..7ef6244c62 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -415,7 +415,7 @@ static int show_info(const char *verb, sd_bus *bus, const char *path, bool *new_
map,
&info);
if (r < 0) {
- log_error("Could not get properties: %s", strerror(-r));
+ log_error_errno(-r, "Could not get properties: %m");
return r;
}
@@ -445,7 +445,7 @@ static int show_properties(sd_bus *bus, const char *path, bool *new_line) {
r = bus_print_all_properties(bus, "org.freedesktop.machine1", path, arg_property, arg_all);
if (r < 0)
- log_error("Could not get properties: %s", strerror(-r));
+ log_error_errno(-r, "Could not get properties: %m");
return r;
}
@@ -682,13 +682,13 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) {
r = sd_event_default(&event);
if (r < 0) {
- log_error("Failed to get event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get event loop: %m");
return r;
}
r = sd_bus_attach_event(bus, event, 0);
if (r < 0) {
- log_error("Failed to attach bus to event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to attach bus to event loop: %m");
return r;
}
@@ -720,7 +720,7 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) {
&reply2,
"u");
if (r < 0) {
- log_error("Failed to retrieve PID of leader: %s", strerror(-r));
+ log_error_errno(-r, "Failed to retrieve PID of leader: %m");
return r;
}
@@ -730,7 +730,7 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) {
master = openpt_in_namespace(leader, O_RDWR|O_NOCTTY|O_CLOEXEC|O_NDELAY);
if (master < 0) {
- log_error("Failed to acquire pseudo tty: %s", strerror(-master));
+ log_error_errno(-master, "Failed to acquire pseudo tty: %m");
return master;
}
@@ -748,7 +748,7 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) {
r = sd_bus_open_system_container(&container_bus, args[1]);
if (r < 0) {
- log_error("Failed to get container bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get container bus: %m");
return r;
}
@@ -786,13 +786,13 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) {
r = pty_forward_new(event, master, &forward);
if (r < 0) {
- log_error("Failed to create PTY forwarder: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create PTY forwarder: %m");
return r;
}
r = sd_event_loop(event);
if (r < 0) {
- log_error("Failed to run event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to run event loop: %m");
return r;
}
@@ -1029,7 +1029,7 @@ int main(int argc, char*argv[]) {
r = bus_open_transport(arg_transport, arg_host, false, &bus);
if (r < 0) {
- log_error("Failed to create bus connection: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create bus connection: %m");
goto finish;
}
diff --git a/src/machine/machined.c b/src/machine/machined.c
index 966475b242..7f03e8281d 100644
--- a/src/machine/machined.c
+++ b/src/machine/machined.c
@@ -113,7 +113,7 @@ int manager_enumerate_machines(Manager *m) {
k = manager_add_machine(m, de->d_name, &machine);
if (k < 0) {
- log_error("Failed to add machine by file name %s: %s", de->d_name, strerror(-k));
+ log_error_errno(-k, "Failed to add machine by file name %s: %m", de->d_name);
r = k;
continue;
@@ -138,25 +138,25 @@ static int manager_connect_bus(Manager *m) {
r = sd_bus_default_system(&m->bus);
if (r < 0) {
- log_error("Failed to connect to system bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to connect to system bus: %m");
return r;
}
r = sd_bus_add_object_vtable(m->bus, NULL, "/org/freedesktop/machine1", "org.freedesktop.machine1.Manager", manager_vtable, m);
if (r < 0) {
- log_error("Failed to add manager object vtable: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add manager object vtable: %m");
return r;
}
r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/machine1/machine", "org.freedesktop.machine1.Machine", machine_vtable, machine_object_find, m);
if (r < 0) {
- log_error("Failed to add machine object vtable: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add machine object vtable: %m");
return r;
}
r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/machine1/machine", machine_node_enumerator, m);
if (r < 0) {
- log_error("Failed to add machine enumerator: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add machine enumerator: %m");
return r;
}
@@ -170,7 +170,7 @@ static int manager_connect_bus(Manager *m) {
match_job_removed,
m);
if (r < 0) {
- log_error("Failed to add match for JobRemoved: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match for JobRemoved: %m");
return r;
}
@@ -184,7 +184,7 @@ static int manager_connect_bus(Manager *m) {
match_unit_removed,
m);
if (r < 0) {
- log_error("Failed to add match for UnitRemoved: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match for UnitRemoved: %m");
return r;
}
@@ -197,7 +197,7 @@ static int manager_connect_bus(Manager *m) {
match_properties_changed,
m);
if (r < 0) {
- log_error("Failed to add match for PropertiesChanged: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match for PropertiesChanged: %m");
return r;
}
@@ -211,7 +211,7 @@ static int manager_connect_bus(Manager *m) {
match_reloading,
m);
if (r < 0) {
- log_error("Failed to add match for Reloading: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match for Reloading: %m");
return r;
}
@@ -230,13 +230,13 @@ static int manager_connect_bus(Manager *m) {
r = sd_bus_request_name(m->bus, "org.freedesktop.machine1", 0);
if (r < 0) {
- log_error("Failed to register name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register name: %m");
return r;
}
r = sd_bus_attach_event(m->bus, m->event, 0);
if (r < 0) {
- log_error("Failed to attach bus to event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to attach bus to event loop: %m");
return r;
}
@@ -335,7 +335,7 @@ int main(int argc, char *argv[]) {
r = manager_startup(m);
if (r < 0) {
- log_error("Failed to fully start up daemon: %s", strerror(-r));
+ log_error_errno(-r, "Failed to fully start up daemon: %m");
goto finish;
}
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
index 5353814d17..30c67a41bd 100644
--- a/src/modules-load/modules-load.c
+++ b/src/modules-load/modules-load.c
@@ -82,7 +82,7 @@ static int load_module(struct kmod_ctx *ctx, const char *m) {
r = kmod_module_new_from_lookup(ctx, m, &modlist);
if (r < 0) {
- log_error("Failed to lookup alias '%s': %s", m, strerror(-r));
+ log_error_errno(-r, "Failed to lookup alias '%s': %m", m);
return r;
}
@@ -142,7 +142,7 @@ static int apply_file(struct kmod_ctx *ctx, const char *path, bool ignore_enoent
if (ignore_enoent && r == -ENOENT)
return 0;
- log_error("Failed to open %s, ignoring: %s", path, strerror(-r));
+ log_error_errno(-r, "Failed to open %s, ignoring: %m", path);
return r;
}
@@ -237,7 +237,7 @@ int main(int argc, char *argv[]) {
r = parse_proc_cmdline(parse_proc_cmdline_item);
if (r < 0)
- log_warning("Failed to parse kernel command line, ignoring: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to parse kernel command line, ignoring: %m");
ctx = kmod_new(NULL, NULL);
if (!ctx) {
@@ -271,7 +271,7 @@ int main(int argc, char *argv[]) {
k = conf_files_list_nulstr(&files, ".conf", NULL, conf_file_dirs);
if (k < 0) {
- log_error("Failed to enumerate modules-load.d files: %s", strerror(-k));
+ log_error_errno(-k, "Failed to enumerate modules-load.d files: %m");
if (r == 0)
r = k;
goto finish;
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index b374121fbc..3e21d9acb8 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -191,7 +191,7 @@ static int list_links(char **args, unsigned n) {
r = sd_rtnl_open(&rtnl, 0);
if (r < 0) {
- log_error("Failed to connect to netlink: %s", strerror(-r));
+ log_error_errno(-r, "Failed to connect to netlink: %m");
return r;
}
@@ -211,7 +211,7 @@ static int list_links(char **args, unsigned n) {
r = sd_rtnl_call(rtnl, req, 0, &reply);
if (r < 0) {
- log_error("Failed to enumerate links: %s", strerror(-r));
+ log_error_errno(-r, "Failed to enumerate links: %m");
return r;
}
@@ -323,7 +323,7 @@ static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
r = sd_rtnl_call(rtnl, req, 0, &reply);
if (r < 0) {
- log_error("Failed to query link: %s", strerror(-r));
+ log_error_errno(-r, "Failed to query link: %m");
return r;
}
@@ -448,7 +448,7 @@ static int link_status(char **args, unsigned n) {
r = sd_rtnl_open(&rtnl, 0);
if (r < 0) {
- log_error("Failed to connect to netlink: %s", strerror(-r));
+ log_error_errno(-r, "Failed to connect to netlink: %m");
return r;
}
@@ -514,7 +514,7 @@ static int link_status(char **args, unsigned n) {
r = sd_rtnl_call(rtnl, req, 0, &reply);
if (r < 0) {
- log_error("Failed to enumerate links: %s", strerror(-r));
+ log_error_errno(-r, "Failed to enumerate links: %m");
return r;
}
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index cf49909858..b85044d292 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -125,7 +125,7 @@ int address_drop(Address *address, Link *link,
r = sd_rtnl_message_addr_set_prefixlen(req, address->prefixlen);
if (r < 0) {
- log_error("Could not set prefixlen: %s", strerror(-r));
+ log_error_errno(-r, "Could not set prefixlen: %m");
return r;
}
@@ -141,7 +141,7 @@ int address_drop(Address *address, Link *link,
r = sd_rtnl_call_async(link->manager->rtnl, req, callback, link, 0, NULL);
if (r < 0) {
- log_error("Could not send rtnetlink message: %s", strerror(-r));
+ log_error_errno(-r, "Could not send rtnetlink message: %m");
return r;
}
@@ -171,19 +171,19 @@ int address_update(Address *address, Link *link,
r = sd_rtnl_message_addr_set_prefixlen(req, address->prefixlen);
if (r < 0) {
- log_error("Could not set prefixlen: %s", strerror(-r));
+ log_error_errno(-r, "Could not set prefixlen: %m");
return r;
}
r = sd_rtnl_message_addr_set_flags(req, IFA_F_PERMANENT);
if (r < 0) {
- log_error("Could not set flags: %s", strerror(-r));
+ log_error_errno(-r, "Could not set flags: %m");
return r;
}
r = sd_rtnl_message_addr_set_scope(req, address->scope);
if (r < 0) {
- log_error("Could not set scope: %s", strerror(-r));
+ log_error_errno(-r, "Could not set scope: %m");
return r;
}
@@ -224,7 +224,7 @@ int address_update(Address *address, Link *link,
r = sd_rtnl_call_async(link->manager->rtnl, req, callback, link, 0, NULL);
if (r < 0) {
- log_error("Could not send rtnetlink message: %s", strerror(-r));
+ log_error_errno(-r, "Could not send rtnetlink message: %m");
return r;
}
@@ -320,19 +320,19 @@ int address_configure(Address *address, Link *link,
r = sd_rtnl_message_addr_set_prefixlen(req, address->prefixlen);
if (r < 0) {
- log_error("Could not set prefixlen: %s", strerror(-r));
+ log_error_errno(-r, "Could not set prefixlen: %m");
return r;
}
r = sd_rtnl_message_addr_set_flags(req, IFA_F_PERMANENT);
if (r < 0) {
- log_error("Could not set flags: %s", strerror(-r));
+ log_error_errno(-r, "Could not set flags: %m");
return r;
}
r = sd_rtnl_message_addr_set_scope(req, address->scope);
if (r < 0) {
- log_error("Could not set scope: %s", strerror(-r));
+ log_error_errno(-r, "Could not set scope: %m");
return r;
}
@@ -386,7 +386,7 @@ int address_configure(Address *address, Link *link,
r = sd_rtnl_call_async(link->manager->rtnl, req, callback, link, 0, NULL);
if (r < 0) {
- log_error("Could not send rtnetlink message: %s", strerror(-r));
+ log_error_errno(-r, "Could not send rtnetlink message: %m");
return r;
}
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index 6046dc7d62..e2190b591e 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -357,7 +357,7 @@ int manager_udev_listen(Manager *m) {
r = udev_monitor_filter_add_match_subsystem_devtype(m->udev_monitor, "net", NULL);
if (r < 0) {
- log_error("Could not add udev monitor filter: %s", strerror(-r));
+ log_error_errno(-r, "Could not add udev monitor filter: %m");
return r;
}
@@ -597,7 +597,7 @@ int manager_save(Manager *m) {
return 0;
fail:
- log_error("Failed to save network state to %s: %s", m->state_file, strerror(-r));
+ log_error_errno(-r, "Failed to save network state to %s: %m", m->state_file);
unlink(m->state_file);
unlink(temp_path);
return r;
diff --git a/src/network/networkd-netdev-veth.c b/src/network/networkd-netdev-veth.c
index 859c26e931..ed43e1b2a9 100644
--- a/src/network/networkd-netdev-veth.c
+++ b/src/network/networkd-netdev-veth.c
@@ -47,7 +47,7 @@ static int netdev_veth_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
if (v->ifname_peer) {
r = sd_rtnl_message_append_string(m, IFLA_IFNAME, v->ifname_peer);
if (r < 0) {
- log_error("Failed to add netlink interface name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add netlink interface name: %m");
return r;
}
}
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index 310b20ae3e..071ca4dcc5 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -744,7 +744,7 @@ int netdev_load(Manager *manager) {
r = conf_files_list_strv(&files, ".netdev", NULL, network_dirs);
if (r < 0) {
- log_error("Failed to enumerate netdev files: %s", strerror(-r));
+ log_error_errno(-r, "Failed to enumerate netdev files: %m");
return r;
}
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index aad99236c4..79b8e75eba 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -132,7 +132,7 @@ int network_load(Manager *manager) {
r = conf_files_list_strv(&files, ".network", NULL, network_dirs);
if (r < 0) {
- log_error("Failed to enumerate network files: %s", strerror(-r));
+ log_error_errno(-r, "Failed to enumerate network files: %m");
return r;
}
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index 82c9e002fd..6db1bcffbd 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -114,7 +114,7 @@ int route_drop(Route *route, Link *link,
RTM_DELROUTE, route->family,
route->protocol);
if (r < 0) {
- log_error("Could not create RTM_DELROUTE message: %s", strerror(-r));
+ log_error_errno(-r, "Could not create RTM_DELROUTE message: %m");
return r;
}
@@ -124,7 +124,7 @@ int route_drop(Route *route, Link *link,
else if (route->family == AF_INET6)
r = sd_rtnl_message_append_in6_addr(req, RTA_GATEWAY, &route->in_addr.in6);
if (r < 0) {
- log_error("Could not append RTA_GATEWAY attribute: %s", strerror(-r));
+ log_error_errno(-r, "Could not append RTA_GATEWAY attribute: %m");
return r;
}
}
@@ -135,13 +135,13 @@ int route_drop(Route *route, Link *link,
else if (route->family == AF_INET6)
r = sd_rtnl_message_append_in6_addr(req, RTA_DST, &route->dst_addr.in6);
if (r < 0) {
- log_error("Could not append RTA_DST attribute: %s", strerror(-r));
+ log_error_errno(-r, "Could not append RTA_DST attribute: %m");
return r;
}
r = sd_rtnl_message_route_set_dst_prefixlen(req, route->dst_prefixlen);
if (r < 0) {
- log_error("Could not set destination prefix length: %s", strerror(-r));
+ log_error_errno(-r, "Could not set destination prefix length: %m");
return r;
}
}
@@ -152,32 +152,32 @@ int route_drop(Route *route, Link *link,
else if (route->family == AF_INET6)
r = sd_rtnl_message_append_in6_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in6);
if (r < 0) {
- log_error("Could not append RTA_PREFSRC attribute: %s", strerror(-r));
+ log_error_errno(-r, "Could not append RTA_PREFSRC attribute: %m");
return r;
}
}
r = sd_rtnl_message_route_set_scope(req, route->scope);
if (r < 0) {
- log_error("Could not set scope: %s", strerror(-r));
+ log_error_errno(-r, "Could not set scope: %m");
return r;
}
r = sd_rtnl_message_append_u32(req, RTA_PRIORITY, route->metrics);
if (r < 0) {
- log_error("Could not append RTA_PRIORITY attribute: %s", strerror(-r));
+ log_error_errno(-r, "Could not append RTA_PRIORITY attribute: %m");
return r;
}
r = sd_rtnl_message_append_u32(req, RTA_OIF, link->ifindex);
if (r < 0) {
- log_error("Could not append RTA_OIF attribute: %s", strerror(-r));
+ log_error_errno(-r, "Could not append RTA_OIF attribute: %m");
return r;
}
r = sd_rtnl_call_async(link->manager->rtnl, req, callback, link, 0, NULL);
if (r < 0) {
- log_error("Could not send rtnetlink message: %s", strerror(-r));
+ log_error_errno(-r, "Could not send rtnetlink message: %m");
return r;
}
@@ -201,7 +201,7 @@ int route_configure(Route *route, Link *link,
RTM_NEWROUTE, route->family,
route->protocol);
if (r < 0) {
- log_error("Could not create RTM_NEWROUTE message: %s", strerror(-r));
+ log_error_errno(-r, "Could not create RTM_NEWROUTE message: %m");
return r;
}
@@ -211,7 +211,7 @@ int route_configure(Route *route, Link *link,
else if (route->family == AF_INET6)
r = sd_rtnl_message_append_in6_addr(req, RTA_GATEWAY, &route->in_addr.in6);
if (r < 0) {
- log_error("Could not append RTA_GATEWAY attribute: %s", strerror(-r));
+ log_error_errno(-r, "Could not append RTA_GATEWAY attribute: %m");
return r;
}
}
@@ -222,13 +222,13 @@ int route_configure(Route *route, Link *link,
else if (route->family == AF_INET6)
r = sd_rtnl_message_append_in6_addr(req, RTA_DST, &route->dst_addr.in6);
if (r < 0) {
- log_error("Could not append RTA_DST attribute: %s", strerror(-r));
+ log_error_errno(-r, "Could not append RTA_DST attribute: %m");
return r;
}
r = sd_rtnl_message_route_set_dst_prefixlen(req, route->dst_prefixlen);
if (r < 0) {
- log_error("Could not set destination prefix length: %s", strerror(-r));
+ log_error_errno(-r, "Could not set destination prefix length: %m");
return r;
}
}
@@ -239,32 +239,32 @@ int route_configure(Route *route, Link *link,
else if (route->family == AF_INET6)
r = sd_rtnl_message_append_in6_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in6);
if (r < 0) {
- log_error("Could not append RTA_PREFSRC attribute: %s", strerror(-r));
+ log_error_errno(-r, "Could not append RTA_PREFSRC attribute: %m");
return r;
}
}
r = sd_rtnl_message_route_set_scope(req, route->scope);
if (r < 0) {
- log_error("Could not set scope: %s", strerror(-r));
+ log_error_errno(-r, "Could not set scope: %m");
return r;
}
r = sd_rtnl_message_append_u32(req, RTA_PRIORITY, route->metrics);
if (r < 0) {
- log_error("Could not append RTA_PRIORITY attribute: %s", strerror(-r));
+ log_error_errno(-r, "Could not append RTA_PRIORITY attribute: %m");
return r;
}
r = sd_rtnl_message_append_u32(req, RTA_OIF, link->ifindex);
if (r < 0) {
- log_error("Could not append RTA_OIF attribute: %s", strerror(-r));
+ log_error_errno(-r, "Could not append RTA_OIF attribute: %m");
return r;
}
r = sd_rtnl_call_async(link->manager->rtnl, req, callback, link, 0, NULL);
if (r < 0) {
- log_error("Could not send rtnetlink message: %s", strerror(-r));
+ log_error_errno(-r, "Could not send rtnetlink message: %m");
return r;
}
diff --git a/src/network/networkd-wait-online-manager.c b/src/network/networkd-wait-online-manager.c
index b32f222701..0cdc4f8811 100644
--- a/src/network/networkd-wait-online-manager.c
+++ b/src/network/networkd-wait-online-manager.c
@@ -134,7 +134,7 @@ static int manager_process_link(sd_rtnl *rtnl, sd_rtnl_message *mm, void *userda
return 0;
fail:
- log_warning("Failed to process RTNL link message: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to process RTNL link message: %m");
return 0;
}
@@ -211,7 +211,7 @@ static int on_network_event(sd_event_source *s, int fd, uint32_t revents, void *
HASHMAP_FOREACH(l, m->links, i) {
r = link_update_monitor(l);
if (r < 0)
- log_warning("Failed to update monitor information for %i: %s", l->ifindex, strerror(-r));
+ log_warning_errno(-r, "Failed to update monitor information for %i: %m", l->ifindex);
}
if (manager_all_configured(m))
diff --git a/src/network/networkd-wait-online.c b/src/network/networkd-wait-online.c
index 714343656b..40c89653b3 100644
--- a/src/network/networkd-wait-online.c
+++ b/src/network/networkd-wait-online.c
@@ -113,7 +113,7 @@ int main(int argc, char *argv[]) {
r = manager_new(&m, arg_interfaces);
if (r < 0) {
- log_error("Could not create manager: %s", strerror(-r));
+ log_error_errno(-r, "Could not create manager: %m");
goto finish;
}
@@ -128,7 +128,7 @@ int main(int argc, char *argv[]) {
r = sd_event_loop(m->event);
if (r < 0) {
- log_error("Event loop failed: %s", strerror(-r));
+ log_error_errno(-r, "Event loop failed: %m");
goto finish;
}
diff --git a/src/network/networkd.c b/src/network/networkd.c
index fdb80368d4..1020c72525 100644
--- a/src/network/networkd.c
+++ b/src/network/networkd.c
@@ -46,7 +46,7 @@ int main(int argc, char *argv[]) {
r = get_user_creds(&user, &uid, &gid, NULL, NULL);
if (r < 0) {
- log_error("Cannot resolve user name %s: %s", user, strerror(-r));
+ log_error_errno(-r, "Cannot resolve user name %s: %m", user);
goto out;
}
@@ -79,37 +79,37 @@ int main(int argc, char *argv[]) {
r = manager_new(&m);
if (r < 0) {
- log_error("Could not create manager: %s", strerror(-r));
+ log_error_errno(-r, "Could not create manager: %m");
goto out;
}
r = manager_udev_listen(m);
if (r < 0) {
- log_error("Could not connect to udev: %s", strerror(-r));
+ log_error_errno(-r, "Could not connect to udev: %m");
goto out;
}
r = manager_rtnl_listen(m);
if (r < 0) {
- log_error("Could not connect to rtnl: %s", strerror(-r));
+ log_error_errno(-r, "Could not connect to rtnl: %m");
goto out;
}
r = manager_bus_listen(m);
if (r < 0) {
- log_error("Could not connect to system bus: %s", strerror(-r));
+ log_error_errno(-r, "Could not connect to system bus: %m");
goto out;
}
r = manager_load_config(m);
if (r < 0) {
- log_error("Could not load configuration files: %s", strerror(-r));
+ log_error_errno(-r, "Could not load configuration files: %m");
goto out;
}
r = manager_rtnl_enumerate_links(m);
if (r < 0) {
- log_error("Could not enumerate links: %s", strerror(-r));
+ log_error_errno(-r, "Could not enumerate links: %m");
goto out;
}
@@ -119,7 +119,7 @@ int main(int argc, char *argv[]) {
r = sd_event_loop(m->event);
if (r < 0) {
- log_error("Event loop failed: %s", strerror(-r));
+ log_error_errno(-r, "Event loop failed: %m");
goto out;
}
diff --git a/src/notify/notify.c b/src/notify/notify.c
index a0f757a252..ceb235c1fb 100644
--- a/src/notify/notify.c
+++ b/src/notify/notify.c
@@ -193,7 +193,7 @@ int main(int argc, char* argv[]) {
r = sd_pid_notify(arg_pid, false, n);
if (r < 0) {
- log_error("Failed to notify init system: %s", strerror(-r));
+ log_error_errno(-r, "Failed to notify init system: %m");
goto finish;
}
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 10a520c2db..d06321cd7b 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -673,7 +673,7 @@ static int mount_all(const char *dest) {
t = path_is_mount_point(where, true);
if (t < 0) {
- log_error("Failed to detect whether %s is a mount point: %s", where, strerror(-t));
+ log_error_errno(-t, "Failed to detect whether %s is a mount point: %m", where);
if (r == 0)
r = t;
@@ -688,12 +688,12 @@ static int mount_all(const char *dest) {
t = mkdir_p(where, 0755);
if (t < 0) {
if (mount_table[k].fatal) {
- log_error("Failed to create directory %s: %s", where, strerror(-t));
+ log_error_errno(-t, "Failed to create directory %s: %m", where);
if (r == 0)
r = t;
} else
- log_warning("Failed to create directory %s: %s", where, strerror(-t));
+ log_warning_errno(-t, "Failed to create directory %s: %m", where);
continue;
}
@@ -756,7 +756,7 @@ static int mount_binds(const char *dest, char **l, bool ro) {
} else if (errno == ENOENT) {
r = mkdir_parents_label(where, 0755);
if (r < 0) {
- log_error("Failed to bind mount %s: %s", *x, strerror(-r));
+ log_error_errno(-r, "Failed to bind mount %s: %m", *x);
return r;
}
} else {
@@ -769,7 +769,7 @@ static int mount_binds(const char *dest, char **l, bool ro) {
if (S_ISDIR(source_st.st_mode)) {
r = mkdir_label(where, 0755);
if (r < 0 && errno != EEXIST) {
- log_error("Failed to create mount point %s: %s", where, strerror(-r));
+ log_error_errno(-r, "Failed to create mount point %s: %m", where);
return r;
}
@@ -790,7 +790,7 @@ static int mount_binds(const char *dest, char **l, bool ro) {
} else if (S_ISREG(source_st.st_mode)) {
r = touch(where);
if (r < 0) {
- log_error("Failed to create mount point %s: %s", where, strerror(-r));
+ log_error_errno(-r, "Failed to create mount point %s: %m", where);
return r;
}
@@ -807,7 +807,7 @@ static int mount_binds(const char *dest, char **l, bool ro) {
if (ro) {
r = bind_remount_recursive(where, true);
if (r < 0) {
- log_error("Read-Only bind mount failed: %s", strerror(-r));
+ log_error_errno(-r, "Read-Only bind mount failed: %m");
return r;
}
}
@@ -829,7 +829,7 @@ static int mount_tmpfs(const char *dest) {
r = mkdir_label(where, 0755);
if (r < 0 && errno != EEXIST) {
- log_error("creating mount point for tmpfs %s failed: %s", where, strerror(-r));
+ log_error_errno(-r, "creating mount point for tmpfs %s failed: %m", where);
return r;
}
@@ -895,7 +895,7 @@ static int setup_timezone(const char *dest) {
r = mkdir_parents(where, 0755);
if (r < 0) {
- log_error("Failed to create directory for timezone info %s in container: %s", where, strerror(-r));
+ log_error_errno(-r, "Failed to create directory for timezone info %s in container: %m", where);
return 0;
}
@@ -933,14 +933,14 @@ static int setup_resolv_conf(const char *dest) {
* fails, it fails, but meh... */
r = mkdir_parents(where, 0755);
if (r < 0) {
- log_warning("Failed to create parent directory for resolv.conf %s: %s", where, strerror(-r));
+ log_warning_errno(-r, "Failed to create parent directory for resolv.conf %s: %m", where);
return 0;
}
r = copy_file("/etc/resolv.conf", where, O_TRUNC|O_NOFOLLOW, 0644);
if (r < 0) {
- log_warning("Failed to copy /etc/resolv.conf to %s: %s", where, strerror(-r));
+ log_warning_errno(-r, "Failed to copy /etc/resolv.conf to %s: %m", where);
return 0;
}
@@ -962,7 +962,7 @@ static int setup_volatile_state(const char *directory) {
r = bind_remount_recursive(directory, true);
if (r < 0) {
- log_error("Failed to remount %s read-only: %s", directory, strerror(-r));
+ log_error_errno(-r, "Failed to remount %s read-only: %m", directory);
return r;
}
@@ -1028,7 +1028,7 @@ static int setup_volatile(const char *directory) {
r = bind_remount_recursive(t, true);
if (r < 0) {
- log_error("Failed to remount %s read-only: %s", t, strerror(-r));
+ log_error_errno(-r, "Failed to remount %s read-only: %m", t);
goto fail;
}
@@ -1081,7 +1081,7 @@ static int setup_boot_id(const char *dest) {
r = sd_id128_randomize(&rnd);
if (r < 0) {
- log_error("Failed to generate random boot id: %s", strerror(-r));
+ log_error_errno(-r, "Failed to generate random boot id: %m");
return r;
}
@@ -1089,7 +1089,7 @@ static int setup_boot_id(const char *dest) {
r = write_string_file(from, as_uuid);
if (r < 0) {
- log_error("Failed to write boot id: %s", strerror(-r));
+ log_error_errno(-r, "Failed to write boot id: %m");
return r;
}
@@ -1146,7 +1146,7 @@ static int copy_devnodes(const char *dest) {
} else {
r = mkdir_parents(to, 0775);
if (r < 0) {
- log_error("Failed to create parent directory of %s: %s", to, strerror(-r));
+ log_error_errno(-r, "Failed to create parent directory of %s: %m", to);
return -r;
}
@@ -1193,7 +1193,7 @@ static int setup_dev_console(const char *dest, const char *console) {
r = chmod_and_chown(console, 0600, 0, 0);
if (r < 0) {
- log_error("Failed to correct access mode for TTY: %s", strerror(-r));
+ log_error_errno(-r, "Failed to correct access mode for TTY: %m");
return r;
}
@@ -1256,7 +1256,7 @@ static int setup_kmsg(const char *dest, int kmsg_socket) {
r = chmod_and_chown(from, 0600, 0, 0);
if (r < 0) {
- log_error("Failed to correct access mode for /dev/kmsg: %s", strerror(-r));
+ log_error_errno(-r, "Failed to correct access mode for /dev/kmsg: %m");
return r;
}
@@ -1319,7 +1319,7 @@ static int setup_journal(const char *directory) {
if (r == -ENOENT && arg_link_journal == LINK_AUTO)
return 0;
else if (r < 0) {
- log_error("Failed to read machine ID from %s: %s", p, strerror(-r));
+ log_error_errno(-r, "Failed to read machine ID from %s: %m", p);
return r;
}
@@ -1330,13 +1330,13 @@ static int setup_journal(const char *directory) {
/* Verify validity */
r = sd_id128_from_string(id, &machine_id);
if (r < 0) {
- log_error("Failed to parse machine ID from %s: %s", p, strerror(-r));
+ log_error_errno(-r, "Failed to parse machine ID from %s: %m", p);
return r;
}
r = sd_id128_get_machine(&this_id);
if (r < 0) {
- log_error("Failed to retrieve machine ID: %s", strerror(-r));
+ log_error_errno(-r, "Failed to retrieve machine ID: %m");
return r;
}
@@ -1476,7 +1476,7 @@ static int register_machine(pid_t pid, int local_ifindex) {
r = sd_bus_default_system(&bus);
if (r < 0) {
- log_error("Failed to open system bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to open system bus: %m");
return r;
}
@@ -1508,7 +1508,7 @@ static int register_machine(pid_t pid, int local_ifindex) {
"org.freedesktop.machine1.Manager",
"CreateMachineWithNetwork");
if (r < 0) {
- log_error("Failed to create message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create message: %m");
return r;
}
@@ -1523,27 +1523,27 @@ static int register_machine(pid_t pid, int local_ifindex) {
strempty(arg_directory),
local_ifindex > 0 ? 1 : 0, local_ifindex);
if (r < 0) {
- log_error("Failed to append message arguments: %s", strerror(-r));
+ log_error_errno(-r, "Failed to append message arguments: %m");
return r;
}
r = sd_bus_message_open_container(m, 'a', "(sv)");
if (r < 0) {
- log_error("Failed to open container: %s", strerror(-r));
+ log_error_errno(-r, "Failed to open container: %m");
return r;
}
if (!isempty(arg_slice)) {
r = sd_bus_message_append(m, "(sv)", "Slice", "s", arg_slice);
if (r < 0) {
- log_error("Failed to append slice: %s", strerror(-r));
+ log_error_errno(-r, "Failed to append slice: %m");
return r;
}
}
r = sd_bus_message_append(m, "(sv)", "DevicePolicy", "s", "strict");
if (r < 0) {
- log_error("Failed to add device policy: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add device policy: %m");
return r;
}
@@ -1569,13 +1569,13 @@ static int register_machine(pid_t pid, int local_ifindex) {
"/dev/pts/ptmx", "rw",
"char-pts", "rw");
if (r < 0) {
- log_error("Failed to add device whitelist: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add device whitelist: %m");
return r;
}
r = sd_bus_message_close_container(m);
if (r < 0) {
- log_error("Failed to close container: %s", strerror(-r));
+ log_error_errno(-r, "Failed to close container: %m");
return r;
}
@@ -1602,7 +1602,7 @@ static int terminate_machine(pid_t pid) {
r = sd_bus_default_system(&bus);
if (r < 0) {
- log_error("Failed to open system bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to open system bus: %m");
return r;
}
@@ -1656,7 +1656,7 @@ static int reset_audit_loginuid(void) {
if (r == -ENOENT)
return 0;
if (r < 0) {
- log_error("Failed to read /proc/self/loginuid: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read /proc/self/loginuid: %m");
return r;
}
@@ -1746,85 +1746,85 @@ static int setup_veth(pid_t pid, char iface_name[IFNAMSIZ], int *ifi) {
r = sd_rtnl_open(&rtnl, 0);
if (r < 0) {
- log_error("Failed to connect to netlink: %s", strerror(-r));
+ log_error_errno(-r, "Failed to connect to netlink: %m");
return r;
}
r = sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0);
if (r < 0) {
- log_error("Failed to allocate netlink message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate netlink message: %m");
return r;
}
r = sd_rtnl_message_append_string(m, IFLA_IFNAME, iface_name);
if (r < 0) {
- log_error("Failed to add netlink interface name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add netlink interface name: %m");
return r;
}
r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, &mac_host);
if (r < 0) {
- log_error("Failed to add netlink MAC address: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add netlink MAC address: %m");
return r;
}
r = sd_rtnl_message_open_container(m, IFLA_LINKINFO);
if (r < 0) {
- log_error("Failed to open netlink container: %s", strerror(-r));
+ log_error_errno(-r, "Failed to open netlink container: %m");
return r;
}
r = sd_rtnl_message_open_container_union(m, IFLA_INFO_DATA, "veth");
if (r < 0) {
- log_error("Failed to open netlink container: %s", strerror(-r));
+ log_error_errno(-r, "Failed to open netlink container: %m");
return r;
}
r = sd_rtnl_message_open_container(m, VETH_INFO_PEER);
if (r < 0) {
- log_error("Failed to open netlink container: %s", strerror(-r));
+ log_error_errno(-r, "Failed to open netlink container: %m");
return r;
}
r = sd_rtnl_message_append_string(m, IFLA_IFNAME, "host0");
if (r < 0) {
- log_error("Failed to add netlink interface name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add netlink interface name: %m");
return r;
}
r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, &mac_container);
if (r < 0) {
- log_error("Failed to add netlink MAC address: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add netlink MAC address: %m");
return r;
}
r = sd_rtnl_message_append_u32(m, IFLA_NET_NS_PID, pid);
if (r < 0) {
- log_error("Failed to add netlink namespace field: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add netlink namespace field: %m");
return r;
}
r = sd_rtnl_message_close_container(m);
if (r < 0) {
- log_error("Failed to close netlink container: %s", strerror(-r));
+ log_error_errno(-r, "Failed to close netlink container: %m");
return r;
}
r = sd_rtnl_message_close_container(m);
if (r < 0) {
- log_error("Failed to close netlink container: %s", strerror(-r));
+ log_error_errno(-r, "Failed to close netlink container: %m");
return r;
}
r = sd_rtnl_message_close_container(m);
if (r < 0) {
- log_error("Failed to close netlink container: %s", strerror(-r));
+ log_error_errno(-r, "Failed to close netlink container: %m");
return r;
}
r = sd_rtnl_call(rtnl, m, 0, NULL);
if (r < 0) {
- log_error("Failed to add new veth interfaces: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add new veth interfaces: %m");
return r;
}
@@ -1863,37 +1863,37 @@ static int setup_bridge(const char veth_name[], int *ifi) {
r = sd_rtnl_open(&rtnl, 0);
if (r < 0) {
- log_error("Failed to connect to netlink: %s", strerror(-r));
+ log_error_errno(-r, "Failed to connect to netlink: %m");
return r;
}
r = sd_rtnl_message_new_link(rtnl, &m, RTM_SETLINK, 0);
if (r < 0) {
- log_error("Failed to allocate netlink message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate netlink message: %m");
return r;
}
r = sd_rtnl_message_link_set_flags(m, IFF_UP, IFF_UP);
if (r < 0) {
- log_error("Failed to set IFF_UP flag: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set IFF_UP flag: %m");
return r;
}
r = sd_rtnl_message_append_string(m, IFLA_IFNAME, veth_name);
if (r < 0) {
- log_error("Failed to add netlink interface name field: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add netlink interface name field: %m");
return r;
}
r = sd_rtnl_message_append_u32(m, IFLA_MASTER, bridge);
if (r < 0) {
- log_error("Failed to add netlink master field: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add netlink master field: %m");
return r;
}
r = sd_rtnl_call(rtnl, m, 0, NULL);
if (r < 0) {
- log_error("Failed to add veth interface to bridge: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add veth interface to bridge: %m");
return r;
}
@@ -1940,7 +1940,7 @@ static int move_network_interfaces(pid_t pid) {
r = sd_rtnl_open(&rtnl, 0);
if (r < 0) {
- log_error("Failed to connect to netlink: %s", strerror(-r));
+ log_error_errno(-r, "Failed to connect to netlink: %m");
return r;
}
@@ -1960,19 +1960,19 @@ static int move_network_interfaces(pid_t pid) {
r = sd_rtnl_message_new_link(rtnl, &m, RTM_SETLINK, ifi);
if (r < 0) {
- log_error("Failed to allocate netlink message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate netlink message: %m");
return r;
}
r = sd_rtnl_message_append_u32(m, IFLA_NET_NS_PID, pid);
if (r < 0) {
- log_error("Failed to append namespace PID to netlink message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to append namespace PID to netlink message: %m");
return r;
}
r = sd_rtnl_call(rtnl, m, 0, NULL);
if (r < 0) {
- log_error("Failed to move interface %s to namespace: %s", *i, strerror(-r));
+ log_error_errno(-r, "Failed to move interface %s to namespace: %m", *i);
return r;
}
}
@@ -1994,7 +1994,7 @@ static int setup_macvlan(pid_t pid) {
r = sd_rtnl_open(&rtnl, 0);
if (r < 0) {
- log_error("Failed to connect to netlink: %s", strerror(-r));
+ log_error_errno(-r, "Failed to connect to netlink: %m");
return r;
}
@@ -2015,13 +2015,13 @@ static int setup_macvlan(pid_t pid) {
r = sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0);
if (r < 0) {
- log_error("Failed to allocate netlink message: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate netlink message: %m");
return r;
}
r = sd_rtnl_message_append_u32(m, IFLA_LINK, ifi);
if (r < 0) {
- log_error("Failed to add netlink interface index: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add netlink interface index: %m");
return r;
}
@@ -2033,49 +2033,49 @@ static int setup_macvlan(pid_t pid) {
r = sd_rtnl_message_append_string(m, IFLA_IFNAME, n);
if (r < 0) {
- log_error("Failed to add netlink interface name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add netlink interface name: %m");
return r;
}
r = sd_rtnl_message_append_u32(m, IFLA_NET_NS_PID, pid);
if (r < 0) {
- log_error("Failed to add netlink namespace field: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add netlink namespace field: %m");
return r;
}
r = sd_rtnl_message_open_container(m, IFLA_LINKINFO);
if (r < 0) {
- log_error("Failed to open netlink container: %s", strerror(-r));
+ log_error_errno(-r, "Failed to open netlink container: %m");
return r;
}
r = sd_rtnl_message_open_container_union(m, IFLA_INFO_DATA, "macvlan");
if (r < 0) {
- log_error("Failed to open netlink container: %s", strerror(-r));
+ log_error_errno(-r, "Failed to open netlink container: %m");
return r;
}
r = sd_rtnl_message_append_u32(m, IFLA_MACVLAN_MODE, MACVLAN_MODE_BRIDGE);
if (r < 0) {
- log_error("Failed to append macvlan mode: %s", strerror(-r));
+ log_error_errno(-r, "Failed to append macvlan mode: %m");
return r;
}
r = sd_rtnl_message_close_container(m);
if (r < 0) {
- log_error("Failed to close netlink container: %s", strerror(-r));
+ log_error_errno(-r, "Failed to close netlink container: %m");
return r;
}
r = sd_rtnl_message_close_container(m);
if (r < 0) {
- log_error("Failed to close netlink container: %s", strerror(-r));
+ log_error_errno(-r, "Failed to close netlink container: %m");
return r;
}
r = sd_rtnl_call(rtnl, m, 0, NULL);
if (r < 0) {
- log_error("Failed to add new macvlan interfaces: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add new macvlan interfaces: %m");
return r;
}
}
@@ -2108,7 +2108,7 @@ static int setup_seccomp(void) {
r = seccomp_add_secondary_archs(seccomp);
if (r < 0) {
- log_error("Failed to add secondary archs to seccomp filter: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add secondary archs to seccomp filter: %m");
goto finish;
}
@@ -2117,7 +2117,7 @@ static int setup_seccomp(void) {
if (r == -EFAULT)
continue; /* unknown syscall */
if (r < 0) {
- log_error("Failed to block syscall: %s", strerror(-r));
+ log_error_errno(-r, "Failed to block syscall: %m");
goto finish;
}
}
@@ -2140,19 +2140,19 @@ static int setup_seccomp(void) {
SCMP_A0(SCMP_CMP_EQ, AF_NETLINK),
SCMP_A2(SCMP_CMP_EQ, NETLINK_AUDIT));
if (r < 0) {
- log_error("Failed to add audit seccomp rule: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add audit seccomp rule: %m");
goto finish;
}
r = seccomp_attr_set(seccomp, SCMP_FLTATR_CTL_NNP, 0);
if (r < 0) {
- log_error("Failed to unset NO_NEW_PRIVS: %s", strerror(-r));
+ log_error_errno(-r, "Failed to unset NO_NEW_PRIVS: %m");
goto finish;
}
r = seccomp_load(seccomp);
if (r < 0)
- log_error("Failed to install seccomp audit filter: %s", strerror(-r));
+ log_error_errno(-r, "Failed to install seccomp audit filter: %m");
finish:
seccomp_release(seccomp);
@@ -2350,7 +2350,7 @@ static int dissect_image(
r = udev_enumerate_scan_devices(e);
if (r < 0) {
- log_error("Failed to scan for partition devices of %s: %s", arg_image, strerror(-r));
+ log_error_errno(-r, "Failed to scan for partition devices of %s: %m", arg_image);
return r;
}
@@ -2581,7 +2581,7 @@ static int mount_devices(
if (root_device) {
r = mount_device(root_device, arg_directory, NULL, root_device_rw);
if (r < 0) {
- log_error("Failed to mount root directory: %s", strerror(-r));
+ log_error_errno(-r, "Failed to mount root directory: %m");
return r;
}
}
@@ -2589,7 +2589,7 @@ static int mount_devices(
if (home_device) {
r = mount_device(home_device, arg_directory, "/home", home_device_rw);
if (r < 0) {
- log_error("Failed to mount home directory: %s", strerror(-r));
+ log_error_errno(-r, "Failed to mount home directory: %m");
return r;
}
}
@@ -2597,7 +2597,7 @@ static int mount_devices(
if (srv_device) {
r = mount_device(srv_device, arg_directory, "/srv", srv_device_rw);
if (r < 0) {
- log_error("Failed to mount server data directory: %s", strerror(-r));
+ log_error_errno(-r, "Failed to mount server data directory: %m");
return r;
}
}
@@ -2857,13 +2857,13 @@ static int change_uid_gid(char **_home) {
r = mkdir_parents(home, 0775);
if (r < 0) {
- log_error("Failed to make home root directory: %s", strerror(-r));
+ log_error_errno(-r, "Failed to make home root directory: %m");
return r;
}
r = mkdir_safe(home, 0755, uid, gid);
if (r < 0 && r != -EEXIST) {
- log_error("Failed to make home directory: %s", strerror(-r));
+ log_error_errno(-r, "Failed to make home directory: %m");
return r;
}
@@ -2917,7 +2917,7 @@ static int wait_for_container(pid_t pid, ContainerStatus *container) {
r = wait_for_terminate(pid, &status);
if (r < 0) {
- log_warning("Failed to wait for container: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to wait for container: %m");
return r;
}
@@ -3050,7 +3050,7 @@ int main(int argc, char *argv[]) {
if (n_fd_passed > 0) {
k = fdset_new_listen_fds(&fds, false);
if (k < 0) {
- log_error("Failed to collect file descriptors: %s", strerror(-k));
+ log_error_errno(-k, "Failed to collect file descriptors: %m");
goto finish;
}
}
@@ -3156,7 +3156,7 @@ int main(int argc, char *argv[]) {
r = barrier_create(&barrier);
if (r < 0) {
- log_error("Cannot initialize IPC barrier: %s", strerror(-r));
+ log_error_errno(-r, "Cannot initialize IPC barrier: %m");
goto finish;
}
@@ -3230,7 +3230,7 @@ int main(int argc, char *argv[]) {
k = -EINVAL;
}
- log_error("Failed to open console: %s", strerror(-k));
+ log_error_errno(-k, "Failed to open console: %m");
_exit(EXIT_FAILURE);
}
@@ -3287,7 +3287,7 @@ int main(int argc, char *argv[]) {
if (arg_read_only) {
k = bind_remount_recursive(arg_directory, true);
if (k < 0) {
- log_error("Failed to make tree read-only: %s", strerror(-k));
+ log_error_errno(-k, "Failed to make tree read-only: %m");
_exit(EXIT_FAILURE);
}
}
@@ -3521,7 +3521,7 @@ int main(int argc, char *argv[]) {
r = sd_event_new(&event);
if (r < 0) {
- log_error("Failed to get default event source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get default event source: %m");
goto finish;
}
@@ -3540,13 +3540,13 @@ int main(int argc, char *argv[]) {
r = pty_forward_new(event, master, &forward);
if (r < 0) {
- log_error("Failed to create PTY forwarder: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create PTY forwarder: %m");
goto finish;
}
r = sd_event_loop(event);
if (r < 0) {
- log_error("Failed to run event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to run event loop: %m");
return r;
}
diff --git a/src/path/path.c b/src/path/path.c
index 37f2571fab..e4d8d1d53c 100644
--- a/src/path/path.c
+++ b/src/path/path.c
@@ -88,7 +88,7 @@ static int list_homes(void) {
if (q == -ENXIO)
continue;
if (q < 0) {
- log_error("Failed to query %s: %s", path_table[i], strerror(-r));
+ log_error_errno(-r, "Failed to query %s: %m", path_table[i]);
r = q;
continue;
}
@@ -109,7 +109,7 @@ static int print_home(const char *n) {
r = sd_path_home(i, arg_suffix, &p);
if (r < 0) {
- log_error("Failed to query %s: %s", n, strerror(-r));
+ log_error_errno(-r, "Failed to query %s: %m", n);
return r;
}
diff --git a/src/quotacheck/quotacheck.c b/src/quotacheck/quotacheck.c
index 6f39dae2af..4ebce5cd03 100644
--- a/src/quotacheck/quotacheck.c
+++ b/src/quotacheck/quotacheck.c
@@ -89,7 +89,7 @@ int main(int argc, char *argv[]) {
r = parse_proc_cmdline(parse_proc_cmdline_item);
if (r < 0)
- log_warning("Failed to parse kernel command line, ignoring: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to parse kernel command line, ignoring: %m");
test_files();
diff --git a/src/random-seed/random-seed.c b/src/random-seed/random-seed.c
index af79ecf2a9..90ec8af7b8 100644
--- a/src/random-seed/random-seed.c
+++ b/src/random-seed/random-seed.c
@@ -72,7 +72,7 @@ int main(int argc, char *argv[]) {
r = mkdir_parents_label(RANDOM_SEED, 0755);
if (r < 0) {
- log_error("Failed to create directory " RANDOM_SEED_DIR ": %s", strerror(-r));
+ log_error_errno(-r, "Failed to create directory " RANDOM_SEED_DIR ": %m");
goto finish;
}
diff --git a/src/remount-fs/remount-fs.c b/src/remount-fs/remount-fs.c
index cd7cfe7a47..e30c344310 100644
--- a/src/remount-fs/remount-fs.c
+++ b/src/remount-fs/remount-fs.c
@@ -120,7 +120,7 @@ int main(int argc, char *argv[]) {
k = hashmap_put(pids, UINT_TO_PTR(pid), s);
if (k < 0) {
- log_error("Failed to add PID to set: %s", strerror(-k));
+ log_error_errno(-k, "Failed to add PID to set: %m");
ret = EXIT_FAILURE;
continue;
}
diff --git a/src/resolve-host/resolve-host.c b/src/resolve-host/resolve-host.c
index 49049d2a25..e9c0d69b02 100644
--- a/src/resolve-host/resolve-host.c
+++ b/src/resolve-host/resolve-host.c
@@ -155,7 +155,7 @@ static int resolve_host(sd_bus *bus, const char *name) {
r = in_addr_to_string(family, a, &pretty);
if (r < 0) {
- log_error("%s: failed to print address: %s", name, strerror(-r));
+ log_error_errno(-r, "%s: failed to print address: %m", name);
continue;
}
@@ -614,7 +614,7 @@ int main(int argc, char **argv) {
r = sd_bus_open_system(&bus);
if (r < 0) {
- log_error("sd_bus_open_system: %s", strerror(-r));
+ log_error_errno(-r, "sd_bus_open_system: %m");
goto finish;
}
diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c
index 0029023bcc..517d20eca9 100644
--- a/src/resolve/resolved-bus.c
+++ b/src/resolve/resolved-bus.c
@@ -251,7 +251,7 @@ static void bus_method_resolve_hostname_complete(DnsQuery *q) {
finish:
if (r < 0) {
- log_error("Failed to send hostname reply: %s", strerror(-r));
+ log_error_errno(-r, "Failed to send hostname reply: %m");
sd_bus_reply_method_errno(q->request, -r, NULL);
}
@@ -419,7 +419,7 @@ static void bus_method_resolve_address_complete(DnsQuery *q) {
finish:
if (r < 0) {
- log_error("Failed to send address reply: %s", strerror(-r));
+ log_error_errno(-r, "Failed to send address reply: %m");
sd_bus_reply_method_errno(q->request, -r, NULL);
}
@@ -591,7 +591,7 @@ static void bus_method_resolve_record_complete(DnsQuery *q) {
finish:
if (r < 0) {
- log_error("Failed to send record reply: %s", strerror(-r));
+ log_error_errno(-r, "Failed to send record reply: %m");
sd_bus_reply_method_errno(q->request, -r, NULL);
}
@@ -690,7 +690,7 @@ static int match_prepare_for_sleep(sd_bus *bus, sd_bus_message *message, void *u
r = sd_bus_message_read(message, "b", &b);
if (r < 0) {
- log_debug("Failed to parse PrepareForSleep signal: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to parse PrepareForSleep signal: %m");
return 0;
}
@@ -717,11 +717,11 @@ int manager_connect_bus(Manager *m) {
* boot. Let's try in 5s again. As soon as we have
* kdbus we can stop doing this... */
- log_debug("Failed to connect to bus, trying again in 5s: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to connect to bus, trying again in 5s: %m");
r = sd_event_add_time(m->event, &m->bus_retry_event_source, CLOCK_MONOTONIC, now(CLOCK_MONOTONIC) + 5*USEC_PER_SEC, 0, on_bus_retry, m);
if (r < 0) {
- log_error("Failed to install bus reconnect time event: %s", strerror(-r));
+ log_error_errno(-r, "Failed to install bus reconnect time event: %m");
return r;
}
@@ -730,19 +730,19 @@ int manager_connect_bus(Manager *m) {
r = sd_bus_add_object_vtable(m->bus, NULL, "/org/freedesktop/resolve1", "org.freedesktop.resolve1.Manager", resolve_vtable, m);
if (r < 0) {
- log_error("Failed to register object: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register object: %m");
return r;
}
r = sd_bus_request_name(m->bus, "org.freedesktop.resolve1", 0);
if (r < 0) {
- log_error("Failed to register name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register name: %m");
return r;
}
r = sd_bus_attach_event(m->bus, m->event, 0);
if (r < 0) {
- log_error("Failed to attach bus to event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to attach bus to event loop: %m");
return r;
}
@@ -755,7 +755,7 @@ int manager_connect_bus(Manager *m) {
match_prepare_for_sleep,
m);
if (r < 0)
- log_error("Failed to add match for PrepareForSleep: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match for PrepareForSleep: %m");
return 0;
}
diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c
index fd4f5f7e33..a31e7929b7 100644
--- a/src/resolve/resolved-dns-scope.c
+++ b/src/resolve/resolved-dns-scope.c
@@ -539,7 +539,7 @@ void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p) {
r = dns_packet_extract(p);
if (r < 0) {
- log_debug("Failed to extract resources from incoming packet: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to extract resources from incoming packet: %m");
return;
}
@@ -551,7 +551,7 @@ void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p) {
r = dns_zone_lookup(&s->zone, p->question, &answer, &soa, &tentative);
if (r < 0) {
- log_debug("Failed to lookup key: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to lookup key: %m");
return;
}
if (r == 0)
@@ -562,7 +562,7 @@ void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p) {
r = dns_scope_make_reply_packet(s, DNS_PACKET_ID(p), DNS_RCODE_SUCCESS, p->question, answer, soa, tentative, &reply);
if (r < 0) {
- log_debug("Failed to build reply packet: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to build reply packet: %m");
return;
}
@@ -581,7 +581,7 @@ void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p) {
return;
}
if (fd < 0) {
- log_debug("Failed to get reply socket: %s", strerror(-fd));
+ log_debug_errno(-fd, "Failed to get reply socket: %m");
return;
}
@@ -594,7 +594,7 @@ void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p) {
}
if (r < 0) {
- log_debug("Failed to send reply packet: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to send reply packet: %m");
return;
}
}
@@ -688,13 +688,13 @@ static int on_conflict_dispatch(sd_event_source *es, usec_t usec, void *userdata
r = dns_scope_make_conflict_packet(scope, rr, &p);
if (r < 0) {
- log_error("Failed to make conflict packet: %s", strerror(-r));
+ log_error_errno(-r, "Failed to make conflict packet: %m");
return 0;
}
r = dns_scope_emit(scope, p);
if (r < 0)
- log_debug("Failed to send conflict packet: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to send conflict packet: %m");
}
return 0;
@@ -722,7 +722,7 @@ int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr) {
if (r == -EEXIST || r == 0)
return 0;
if (r < 0) {
- log_debug("Failed to queue conflicting RR: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to queue conflicting RR: %m");
return r;
}
@@ -741,7 +741,7 @@ int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr) {
LLMNR_JITTER_INTERVAL_USEC,
on_conflict_dispatch, scope);
if (r < 0) {
- log_debug("Failed to add conflict dispatch event: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to add conflict dispatch event: %m");
return r;
}
@@ -772,7 +772,7 @@ void dns_scope_check_conflicts(DnsScope *scope, DnsPacket *p) {
r = dns_packet_extract(p);
if (r < 0) {
- log_debug("Failed to extract packet: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to extract packet: %m");
return;
}
diff --git a/src/resolve/resolved-dns-zone.c b/src/resolve/resolved-dns-zone.c
index 8098ff5e70..c463fe9c41 100644
--- a/src/resolve/resolved-dns-zone.c
+++ b/src/resolve/resolved-dns-zone.c
@@ -570,7 +570,7 @@ static int dns_zone_item_verify(DnsZoneItem *i) {
i->state = DNS_ZONE_ITEM_VERIFYING;
r = dns_zone_item_probe_start(i);
if (r < 0) {
- log_error("Failed to start probing for verifying RR: %s", strerror(-r));
+ log_error_errno(-r, "Failed to start probing for verifying RR: %m");
i->state = DNS_ZONE_ITEM_ESTABLISHED;
return r;
}
diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c
index 4def672214..2cbc37ceaa 100644
--- a/src/resolve/resolved-link.c
+++ b/src/resolve/resolved-link.c
@@ -88,7 +88,7 @@ static void link_allocate_scopes(Link *l) {
if (!l->unicast_scope) {
r = dns_scope_new(l->manager, &l->unicast_scope, l, DNS_PROTOCOL_DNS, AF_UNSPEC);
if (r < 0)
- log_warning("Failed to allocate DNS scope: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to allocate DNS scope: %m");
}
} else
l->unicast_scope = dns_scope_free(l->unicast_scope);
@@ -99,7 +99,7 @@ static void link_allocate_scopes(Link *l) {
if (!l->llmnr_ipv4_scope) {
r = dns_scope_new(l->manager, &l->llmnr_ipv4_scope, l, DNS_PROTOCOL_LLMNR, AF_INET);
if (r < 0)
- log_warning("Failed to allocate LLMNR IPv4 scope: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to allocate LLMNR IPv4 scope: %m");
}
} else
l->llmnr_ipv4_scope = dns_scope_free(l->llmnr_ipv4_scope);
@@ -111,7 +111,7 @@ static void link_allocate_scopes(Link *l) {
if (!l->llmnr_ipv6_scope) {
r = dns_scope_new(l->manager, &l->llmnr_ipv6_scope, l, DNS_PROTOCOL_LLMNR, AF_INET6);
if (r < 0)
- log_warning("Failed to allocate LLMNR IPv6 scope: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to allocate LLMNR IPv6 scope: %m");
}
} else
l->llmnr_ipv6_scope = dns_scope_free(l->llmnr_ipv6_scope);
@@ -439,11 +439,11 @@ void link_address_add_rrs(LinkAddress *a, bool force_remove) {
r = dns_zone_put(&a->link->llmnr_ipv4_scope->zone, a->link->llmnr_ipv4_scope, a->llmnr_address_rr, true);
if (r < 0)
- log_warning("Failed to add A record to LLMNR zone: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to add A record to LLMNR zone: %m");
r = dns_zone_put(&a->link->llmnr_ipv4_scope->zone, a->link->llmnr_ipv4_scope, a->llmnr_ptr_rr, false);
if (r < 0)
- log_warning("Failed to add IPv6 PTR record to LLMNR zone: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to add IPv6 PTR record to LLMNR zone: %m");
} else {
if (a->llmnr_address_rr) {
if (a->link->llmnr_ipv4_scope)
@@ -496,11 +496,11 @@ void link_address_add_rrs(LinkAddress *a, bool force_remove) {
r = dns_zone_put(&a->link->llmnr_ipv6_scope->zone, a->link->llmnr_ipv6_scope, a->llmnr_address_rr, true);
if (r < 0)
- log_warning("Failed to add AAAA record to LLMNR zone: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to add AAAA record to LLMNR zone: %m");
r = dns_zone_put(&a->link->llmnr_ipv6_scope->zone, a->link->llmnr_ipv6_scope, a->llmnr_ptr_rr, false);
if (r < 0)
- log_warning("Failed to add IPv6 PTR record to LLMNR zone: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to add IPv6 PTR record to LLMNR zone: %m");
} else {
if (a->llmnr_address_rr) {
if (a->link->llmnr_ipv6_scope)
@@ -519,7 +519,7 @@ void link_address_add_rrs(LinkAddress *a, bool force_remove) {
return;
fail:
- log_debug("Failed to update address RRs: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to update address RRs: %m");
}
int link_address_update_rtnl(LinkAddress *a, sd_rtnl_message *m) {
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index c4a5b08773..43031bc458 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -100,7 +100,7 @@ static int manager_process_link(sd_rtnl *rtnl, sd_rtnl_message *mm, void *userda
return 0;
fail:
- log_warning("Failed to process RTNL link message: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to process RTNL link message: %m");
return 0;
}
@@ -185,7 +185,7 @@ static int manager_process_address(sd_rtnl *rtnl, sd_rtnl_message *mm, void *use
return 0;
fail:
- log_warning("Failed to process RTNL address message: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to process RTNL address message: %m");
return 0;
}
@@ -278,12 +278,12 @@ static int on_network_event(sd_event_source *s, int fd, uint32_t revents, void *
HASHMAP_FOREACH(l, m->links, i) {
r = link_update_monitor(l);
if (r < 0)
- log_warning("Failed to update monitor information for %i: %s", l->ifindex, strerror(-r));
+ log_warning_errno(-r, "Failed to update monitor information for %i: %m", l->ifindex);
}
r = manager_write_resolv_conf(m);
if (r < 0)
- log_warning("Could not update resolv.conf: %s", strerror(-r));
+ log_warning_errno(-r, "Could not update resolv.conf: %m");
return 0;
}
@@ -380,7 +380,7 @@ static int manager_watch_hostname(Manager *m) {
/* kernels prior to 3.2 don't support polling this file. Ignore the failure. */
m->hostname_fd = safe_close(m->hostname_fd);
else {
- log_error("Failed to add hostname event source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add hostname event source: %m");
return r;
}
}
@@ -688,7 +688,7 @@ static void write_resolv_conf_server(DnsServer *s, FILE *f, unsigned *count) {
r = in_addr_to_string(s->family, &s->address, &t);
if (r < 0) {
- log_warning("Invalid DNS address. Ignoring: %s", strerror(-r));
+ log_warning_errno(-r, "Invalid DNS address. Ignoring: %m");
return;
}
diff --git a/src/resolve/resolved.c b/src/resolve/resolved.c
index 6dd4cade05..9150a5e33b 100644
--- a/src/resolve/resolved.c
+++ b/src/resolve/resolved.c
@@ -49,20 +49,20 @@ int main(int argc, char *argv[]) {
r = mac_selinux_init(NULL);
if (r < 0) {
- log_error("SELinux setup failed: %s", strerror(-r));
+ log_error_errno(-r, "SELinux setup failed: %m");
goto finish;
}
r = get_user_creds(&user, &uid, &gid, NULL, NULL);
if (r < 0) {
- log_error("Cannot resolve user name %s: %s", user, strerror(-r));
+ log_error_errno(-r, "Cannot resolve user name %s: %m", user);
goto finish;
}
/* Always create the directory where resolv.conf will live */
r = mkdir_safe_label("/run/systemd/resolve", 0755, uid, gid);
if (r < 0) {
- log_error("Could not create runtime directory: %s", strerror(-r));
+ log_error_errno(-r, "Could not create runtime directory: %m");
goto finish;
}
@@ -74,17 +74,17 @@ int main(int argc, char *argv[]) {
r = manager_new(&m);
if (r < 0) {
- log_error("Could not create manager: %s", strerror(-r));
+ log_error_errno(-r, "Could not create manager: %m");
goto finish;
}
r = manager_parse_config_file(m);
if (r < 0)
- log_warning("Failed to parse configuration file: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to parse configuration file: %m");
r = manager_start(m);
if (r < 0) {
- log_error("Failed to start manager: %s", strerror(-r));
+ log_error_errno(-r, "Failed to start manager: %m");
goto finish;
}
@@ -92,7 +92,7 @@ int main(int argc, char *argv[]) {
* symlink */
r = manager_write_resolv_conf(m);
if (r < 0)
- log_warning("Could not create resolv.conf: %s", strerror(-r));
+ log_warning_errno(-r, "Could not create resolv.conf: %m");
sd_notify(false,
"READY=1\n"
@@ -100,7 +100,7 @@ int main(int argc, char *argv[]) {
r = sd_event_loop(m->event);
if (r < 0) {
- log_error("Event loop failed: %s", strerror(-r));
+ log_error_errno(-r, "Event loop failed: %m");
goto finish;
}
diff --git a/src/rfkill/rfkill.c b/src/rfkill/rfkill.c
index c7c659292a..0acb092418 100644
--- a/src/rfkill/rfkill.c
+++ b/src/rfkill/rfkill.c
@@ -45,7 +45,7 @@ int main(int argc, char *argv[]) {
r = mkdir_p("/var/lib/systemd/rfkill", 0755);
if (r < 0) {
- log_error("Failed to create rfkill directory: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create rfkill directory: %m");
return EXIT_FAILURE;
}
@@ -107,13 +107,13 @@ int main(int argc, char *argv[]) {
if (r == -ENOENT)
return EXIT_SUCCESS;
- log_error("Failed to read %s: %s", saved, strerror(-r));
+ log_error_errno(-r, "Failed to read %s: %m", saved);
return EXIT_FAILURE;
}
r = udev_device_set_sysattr_value(device, "soft", value);
if (r < 0) {
- log_error("Failed to write system attribute: %s", strerror(-r));
+ log_error_errno(-r, "Failed to write system attribute: %m");
return EXIT_FAILURE;
}
@@ -122,13 +122,13 @@ int main(int argc, char *argv[]) {
value = udev_device_get_sysattr_value(device, "soft");
if (!value) {
- log_error("Failed to read system attribute: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read system attribute: %m");
return EXIT_FAILURE;
}
r = write_string_file(saved, value);
if (r < 0) {
- log_error("Failed to write %s: %s", saved, strerror(-r));
+ log_error_errno(-r, "Failed to write %s: %m", saved);
return EXIT_FAILURE;
}
diff --git a/src/run/run.c b/src/run/run.c
index dcefb5c376..14d147c671 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -499,7 +499,7 @@ static int start_transient_scope(
r = get_group_creds(&arg_exec_group, &gid);
if (r < 0) {
- log_error("Failed to resolve group %s: %s", arg_exec_group, strerror(-r));
+ log_error_errno(-r, "Failed to resolve group %s: %m", arg_exec_group);
return r;
}
@@ -516,7 +516,7 @@ static int start_transient_scope(
r = get_user_creds(&arg_exec_user, &uid, &gid, &home, &shell);
if (r < 0) {
- log_error("Failed to resolve user %s: %s", arg_exec_user, strerror(-r));
+ log_error_errno(-r, "Failed to resolve user %s: %m", arg_exec_user);
return r;
}
@@ -595,7 +595,7 @@ int main(int argc, char* argv[]) {
r = bus_open_transport_systemd(arg_transport, arg_host, arg_user, &bus);
if (r < 0) {
- log_error("Failed to create bus connection: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create bus connection: %m");
goto finish;
}
diff --git a/src/shared/capability.c b/src/shared/capability.c
index 0226542c6c..f7513379a2 100644
--- a/src/shared/capability.c
+++ b/src/shared/capability.c
@@ -255,7 +255,7 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) {
r = capability_bounding_set_drop(~keep_capabilities, true);
if (r < 0) {
- log_error("Failed to drop capabilities: %s", strerror(-r));
+ log_error_errno(-r, "Failed to drop capabilities: %m");
return r;
}
diff --git a/src/shared/generator.c b/src/shared/generator.c
index 414470be1c..892fa39ec1 100644
--- a/src/shared/generator.c
+++ b/src/shared/generator.c
@@ -52,10 +52,10 @@ int generator_write_fsck_deps(
r = fsck_exists(fstype);
if (r == -ENOENT) {
/* treat missing check as essentially OK */
- log_debug("Checking was requested for %s, but fsck.%s does not exist: %s", what, fstype, strerror(-r));
+ log_debug_errno(-r, "Checking was requested for %s, but fsck.%s does not exist: %m", what, fstype);
return 0;
} else if (r < 0) {
- log_warning("Checking was requested for %s, but fsck.%s cannot be used: %s", what, fstype, strerror(-r));
+ log_warning_errno(-r, "Checking was requested for %s, but fsck.%s cannot be used: %m", what, fstype);
return r;
}
}
diff --git a/src/shared/install.c b/src/shared/install.c
index 8a7f7e2094..1e90bdf725 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -1554,7 +1554,7 @@ int unit_file_add_dependency(
state = unit_file_get_state(scope, root_dir, *i);
if (state < 0) {
- log_error("Failed to get unit file state for %s: %s", *i, strerror(-state));
+ log_error_errno(-state, "Failed to get unit file state for %s: %m", *i);
return state;
}
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index e33824be4a..32eba6ccfe 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -296,7 +296,7 @@ static int output_short(
r = sd_journal_get_monotonic_usec(j, &t, &boot_id);
if (r < 0) {
- log_error("Failed to get monotonic timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get monotonic timestamp: %m");
return r;
}
@@ -323,7 +323,7 @@ static int output_short(
r = sd_journal_get_realtime_usec(j, &x);
if (r < 0) {
- log_error("Failed to get realtime timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get realtime timestamp: %m");
return r;
}
@@ -422,7 +422,7 @@ static int output_verbose(
r = parse_field(data, length, "_SOURCE_REALTIME_TIMESTAMP=", &value, &size);
if (r < 0)
- log_debug("_SOURCE_REALTIME_TIMESTAMP invalid: %s", strerror(-r));
+ log_debug_errno(-r, "_SOURCE_REALTIME_TIMESTAMP invalid: %m");
else {
r = safe_atou64(value, &realtime);
if (r < 0)
@@ -442,7 +442,7 @@ static int output_verbose(
r = sd_journal_get_cursor(j, &cursor);
if (r < 0) {
- log_error("Failed to get cursor: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get cursor: %m");
return r;
}
@@ -517,19 +517,19 @@ static int output_export(
r = sd_journal_get_realtime_usec(j, &realtime);
if (r < 0) {
- log_error("Failed to get realtime timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get realtime timestamp: %m");
return r;
}
r = sd_journal_get_monotonic_usec(j, &monotonic, &boot_id);
if (r < 0) {
- log_error("Failed to get monotonic timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get monotonic timestamp: %m");
return r;
}
r = sd_journal_get_cursor(j, &cursor);
if (r < 0) {
- log_error("Failed to get cursor: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get cursor: %m");
return r;
}
@@ -657,19 +657,19 @@ static int output_json(
r = sd_journal_get_realtime_usec(j, &realtime);
if (r < 0) {
- log_error("Failed to get realtime timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get realtime timestamp: %m");
return r;
}
r = sd_journal_get_monotonic_usec(j, &monotonic, &boot_id);
if (r < 0) {
- log_error("Failed to get monotonic timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get monotonic timestamp: %m");
return r;
}
r = sd_journal_get_cursor(j, &cursor);
if (r < 0) {
- log_error("Failed to get cursor: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get cursor: %m");
return r;
}
@@ -877,7 +877,7 @@ static int output_cat(
if (r == -ENOENT)
return 0;
- log_error("Failed to get data: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get data: %m");
return r;
}
@@ -1226,13 +1226,13 @@ int add_match_this_boot(sd_journal *j, const char *machine) {
if (machine) {
r = get_boot_id_for_machine(machine, &boot_id);
if (r < 0) {
- log_error("Failed to get boot id of container %s: %s", machine, strerror(-r));
+ log_error_errno(-r, "Failed to get boot id of container %s: %m", machine);
return r;
}
} else {
r = sd_id128_get_boot(&boot_id);
if (r < 0) {
- log_error("Failed to get boot id: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get boot id: %m");
return r;
}
}
@@ -1240,7 +1240,7 @@ int add_match_this_boot(sd_journal *j, const char *machine) {
sd_id128_to_string(boot_id, match + 9);
r = sd_journal_add_match(j, match, strlen(match));
if (r < 0) {
- log_error("Failed to add match: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match: %m");
return r;
}
diff --git a/src/shared/pager.c b/src/shared/pager.c
index 001927ce93..572c26b149 100644
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -186,7 +186,7 @@ int show_man_page(const char *desc, bool null_stdio) {
if (null_stdio) {
r = make_null_stdio();
if (r < 0) {
- log_error("Failed to kill stdio: %s", strerror(-r));
+ log_error_errno(-r, "Failed to kill stdio: %m");
_exit(EXIT_FAILURE);
}
}
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
index d8de644a92..7a4e5cda2b 100644
--- a/src/shared/sleep-config.c
+++ b/src/shared/sleep-config.c
@@ -227,7 +227,7 @@ static bool enough_memory_for_hibernation(void) {
r = get_status_field("/proc/meminfo", "\nActive(anon):", &active);
if (r < 0) {
- log_error("Failed to retrieve Active(anon) from /proc/meminfo: %s", strerror(-r));
+ log_error_errno(-r, "Failed to retrieve Active(anon) from /proc/meminfo: %m");
return false;
}
diff --git a/src/shared/socket-label.c b/src/shared/socket-label.c
index 47d9488d56..b0fca9b45c 100644
--- a/src/shared/socket-label.c
+++ b/src/shared/socket-label.c
@@ -162,12 +162,12 @@ int make_socket_fd(int log_level, const char* address, int flags) {
r = socket_address_print(&a, &p);
if (r < 0) {
- log_error("socket_address_print(): %s", strerror(-r));
+ log_error_errno(-r, "socket_address_print(): %m");
return r;
}
if (fd < 0)
- log_error("Failed to listen on %s: %s", p, strerror(-fd));
+ log_error_errno(-fd, "Failed to listen on %s: %m", p);
else
log_full(log_level, "Listening on %s", p);
}
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
index 911dbfe55a..4457e9d1a2 100644
--- a/src/shared/socket-util.c
+++ b/src/shared/socket-util.c
@@ -637,7 +637,7 @@ int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret)
r = sockaddr_pretty(&sa->sa, salen, true, &ret);
if (r < 0) {
- log_error("sockadd_pretty() failed: %s", strerror(-r));
+ log_error_errno(-r, "sockadd_pretty() failed: %m");
return r;
}
diff --git a/src/shared/spawn-ask-password-agent.c b/src/shared/spawn-ask-password-agent.c
index ff121f86a2..6e31d8d138 100644
--- a/src/shared/spawn-ask-password-agent.c
+++ b/src/shared/spawn-ask-password-agent.c
@@ -49,7 +49,7 @@ int ask_password_agent_open(void) {
SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH,
SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH, "--watch", NULL);
if (r < 0)
- log_error("Failed to fork TTY ask password agent: %s", strerror(-r));
+ log_error_errno(-r, "Failed to fork TTY ask password agent: %m");
return r;
}
diff --git a/src/shared/spawn-polkit-agent.c b/src/shared/spawn-polkit-agent.c
index 7a90ef8013..93652f052d 100644
--- a/src/shared/spawn-polkit-agent.c
+++ b/src/shared/spawn-polkit-agent.c
@@ -64,7 +64,7 @@ int polkit_agent_open(void) {
safe_close(pipe_fd[1]);
if (r < 0)
- log_error("Failed to fork TTY ask password agent: %s", strerror(-r));
+ log_error_errno(-r, "Failed to fork TTY ask password agent: %m");
else
/* Wait until the agent closes the fd */
fd_wait_for_event(pipe_fd[0], POLLHUP, USEC_INFINITY);
diff --git a/src/shared/util.c b/src/shared/util.c
index d3eec5f878..11be757c2f 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -2214,7 +2214,7 @@ int acquire_terminal(
r = reset_terminal_fd(fd, true);
if (r < 0)
- log_warning("Failed to reset terminal: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to reset terminal: %m");
return fd;
@@ -3796,7 +3796,7 @@ int wait_for_terminate_and_warn(const char *name, pid_t pid) {
r = wait_for_terminate(pid, &status);
if (r < 0) {
- log_warning("Failed to wait for %s: %s", name, strerror(-r));
+ log_warning_errno(-r, "Failed to wait for %s: %m", name);
return r;
}
@@ -5507,13 +5507,13 @@ int make_console_stdio(void) {
fd = acquire_terminal("/dev/console", false, true, true, USEC_INFINITY);
if (fd < 0) {
- log_error("Failed to acquire terminal: %s", strerror(-fd));
+ log_error_errno(-fd, "Failed to acquire terminal: %m");
return fd;
}
r = make_stdio(fd);
if (r < 0) {
- log_error("Failed to duplicate terminal fd: %s", strerror(-r));
+ log_error_errno(-r, "Failed to duplicate terminal fd: %m");
return r;
}
diff --git a/src/shutdownd/shutdownd.c b/src/shutdownd/shutdownd.c
index 0f008a6100..c443a90179 100644
--- a/src/shutdownd/shutdownd.c
+++ b/src/shutdownd/shutdownd.c
@@ -204,7 +204,7 @@ static int update_schedule_file(struct sd_shutdown_command *c) {
r = mkdir_safe_label("/run/systemd/shutdown", 0755, 0, 0);
if (r < 0) {
- log_error("Failed to create shutdown subdirectory: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create shutdown subdirectory: %m");
return r;
}
@@ -214,7 +214,7 @@ static int update_schedule_file(struct sd_shutdown_command *c) {
r = fopen_temporary("/run/systemd/shutdown/scheduled", &f, &temp_path);
if (r < 0) {
- log_error("Failed to save information about scheduled shutdowns: %s", strerror(-r));
+ log_error_errno(-r, "Failed to save information about scheduled shutdowns: %m");
return r;
}
@@ -284,7 +284,7 @@ int main(int argc, char *argv[]) {
n_fds = sd_listen_fds(true);
if (n_fds < 0) {
- log_error("Failed to read listening file descriptors from environment: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read listening file descriptors from environment: %m");
return EXIT_FAILURE;
}
@@ -410,7 +410,7 @@ int main(int argc, char *argv[]) {
e = write_string_file_atomic("/run/nologin", "System is going down.");
if (e < 0)
- log_error("Failed to create /run/nologin: %s", strerror(-e));
+ log_error_errno(-e, "Failed to create /run/nologin: %m");
else
unlink_nologin = true;
diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c
index 3041903757..bac7393a5f 100644
--- a/src/socket-proxy/socket-proxyd.c
+++ b/src/socket-proxy/socket-proxyd.c
@@ -266,7 +266,7 @@ static int connection_enable_event_sources(Connection *c) {
r = 0;
if (r < 0) {
- log_error("Failed to set up server event source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set up server event source: %m");
return r;
}
@@ -278,7 +278,7 @@ static int connection_enable_event_sources(Connection *c) {
r = 0;
if (r < 0) {
- log_error("Failed to set up client event source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set up client event source: %m");
return r;
}
@@ -357,13 +357,13 @@ static int connection_start(Connection *c, struct sockaddr *sa, socklen_t salen)
if (errno == EINPROGRESS) {
r = sd_event_add_io(c->context->event, &c->client_event_source, c->client_fd, EPOLLOUT, connect_cb, c);
if (r < 0) {
- log_error("Failed to add connection socket: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add connection socket: %m");
goto fail;
}
r = sd_event_source_set_enabled(c->client_event_source, SD_EVENT_ONESHOT);
if (r < 0) {
- log_error("Failed to enable oneshot event source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to enable oneshot event source: %m");
goto fail;
}
} else {
@@ -449,7 +449,7 @@ static int resolve_remote(Connection *c) {
log_debug("Looking up address info for %s:%s", node, service);
r = sd_resolve_getaddrinfo(c->context->resolve, &c->resolve_query, node, service, &hints, resolve_cb, c);
if (r < 0) {
- log_error("Failed to resolve remote host: %s", strerror(-r));
+ log_error_errno(-r, "Failed to resolve remote host: %m");
goto fail;
}
@@ -521,14 +521,14 @@ static int accept_cb(sd_event_source *s, int fd, uint32_t revents, void *userdat
r = add_connection_socket(context, nfd);
if (r < 0) {
- log_error("Failed to accept connection, ignoring: %s", strerror(-r));
+ log_error_errno(-r, "Failed to accept connection, ignoring: %m");
safe_close(fd);
}
}
r = sd_event_source_set_enabled(s, SD_EVENT_ONESHOT);
if (r < 0) {
- log_error("Error while re-enabling listener with ONESHOT: %s", strerror(-r));
+ log_error_errno(-r, "Error while re-enabling listener with ONESHOT: %m");
sd_event_exit(context->event, r);
return r;
}
@@ -551,7 +551,7 @@ static int add_listen_socket(Context *context, int fd) {
r = sd_is_socket(fd, 0, SOCK_STREAM, 1);
if (r < 0) {
- log_error("Failed to determine socket type: %s", strerror(-r));
+ log_error_errno(-r, "Failed to determine socket type: %m");
return r;
}
if (r == 0) {
@@ -561,19 +561,19 @@ static int add_listen_socket(Context *context, int fd) {
r = fd_nonblock(fd, true);
if (r < 0) {
- log_error("Failed to mark file descriptor non-blocking: %s", strerror(-r));
+ log_error_errno(-r, "Failed to mark file descriptor non-blocking: %m");
return r;
}
r = sd_event_add_io(context->event, &source, fd, EPOLLIN, accept_cb, context);
if (r < 0) {
- log_error("Failed to add event source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add event source: %m");
return r;
}
r = set_put(context->listen, source);
if (r < 0) {
- log_error("Failed to add source to set: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add source to set: %m");
sd_event_source_unref(source);
return r;
}
@@ -582,7 +582,7 @@ static int add_listen_socket(Context *context, int fd) {
* watching to accept(). */
r = sd_event_source_set_enabled(source, SD_EVENT_ONESHOT);
if (r < 0) {
- log_error("Failed to enable oneshot mode: %s", strerror(-r));
+ log_error_errno(-r, "Failed to enable oneshot mode: %m");
return r;
}
@@ -663,19 +663,19 @@ int main(int argc, char *argv[]) {
r = sd_event_default(&context.event);
if (r < 0) {
- log_error("Failed to allocate event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate event loop: %m");
goto finish;
}
r = sd_resolve_default(&context.resolve);
if (r < 0) {
- log_error("Failed to allocate resolver: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate resolver: %m");
goto finish;
}
r = sd_resolve_attach_event(context.resolve, context.event, 0);
if (r < 0) {
- log_error("Failed to attach resolver: %s", strerror(-r));
+ log_error_errno(-r, "Failed to attach resolver: %m");
goto finish;
}
@@ -700,7 +700,7 @@ int main(int argc, char *argv[]) {
r = sd_event_loop(context.event);
if (r < 0) {
- log_error("Failed to run event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to run event loop: %m");
goto finish;
}
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
index edebe501d1..2f73c32049 100644
--- a/src/sysctl/sysctl.c
+++ b/src/sysctl/sysctl.c
@@ -134,7 +134,7 @@ static int parse_file(Hashmap *sysctl_options, const char *path, bool ignore_eno
if (ignore_enoent && r == -ENOENT)
return 0;
- log_error("Failed to open file '%s', ignoring: %s", path, strerror(-r));
+ log_error_errno(-r, "Failed to open file '%s', ignoring: %m", path);
return r;
}
@@ -196,7 +196,7 @@ static int parse_file(Hashmap *sysctl_options, const char *path, bool ignore_eno
k = hashmap_put(sysctl_options, property, new_value);
if (k < 0) {
- log_error("Failed to add sysctl variable %s to hashmap: %s", property, strerror(-k));
+ log_error_errno(-k, "Failed to add sysctl variable %s to hashmap: %m", property);
free(property);
free(new_value);
return k;
@@ -314,7 +314,7 @@ int main(int argc, char *argv[]) {
r = conf_files_list_nulstr(&files, ".conf", NULL, conf_file_dirs);
if (r < 0) {
- log_error("Failed to enumerate sysctl.d files: %s", strerror(-r));
+ log_error_errno(-r, "Failed to enumerate sysctl.d files: %m");
goto finish;
}
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index fd69c6966a..4d1a660e82 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -622,7 +622,7 @@ static int get_unit_list_recursive(
r = sd_bus_open_system_container(&container, *i);
if (r < 0) {
- log_error("Failed to connect to container %s: %s", *i, strerror(-r));
+ log_error_errno(-r, "Failed to connect to container %s: %m", *i);
continue;
}
@@ -1360,7 +1360,7 @@ static int list_unit_files(sd_bus *bus, char **args) {
r = unit_file_get_list(arg_scope, arg_root, h);
if (r < 0) {
unit_file_list_free(h);
- log_error("Failed to get unit file list: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get unit file list: %m");
return r;
}
@@ -1907,7 +1907,7 @@ static int get_default(sd_bus *bus, char **args) {
if (!bus || avoid_bus()) {
r = unit_file_get_default(arg_scope, arg_root, &_path);
if (r < 0) {
- log_error("Failed to get default target: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get default target: %m");
return r;
}
path = _path;
@@ -1990,7 +1990,7 @@ static int set_default(sd_bus *bus, char **args) {
if (!bus || avoid_bus()) {
r = unit_file_set_default(arg_scope, arg_root, unit, true, &changes, &n_changes);
if (r < 0) {
- log_error("Failed to set default target: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set default target: %m");
return r;
}
@@ -2201,7 +2201,7 @@ static int cancel_job(sd_bus *bus, char **args) {
q = safe_atou32(*name, &id);
if (q < 0) {
- log_error("Failed to parse job id \"%s\": %s", *name, strerror(-q));
+ log_error_errno(-q, "Failed to parse job id \"%s\": %m", *name);
return q;
}
@@ -2432,7 +2432,7 @@ static int wait_for_jobs(sd_bus *bus, Set *s) {
while (!set_isempty(s)) {
q = bus_process_wait(bus);
if (q < 0) {
- log_error("Failed to wait for response: %s", strerror(-q));
+ log_error_errno(-q, "Failed to wait for response: %m");
return q;
}
@@ -2561,7 +2561,7 @@ static int check_triggering_units(
STRV_FOREACH(i, triggered_by) {
r = check_one_unit(bus, *i, "active\0reloading\0", true);
if (r < 0) {
- log_error("Failed to check unit: %s", strerror(-r));
+ log_error_errno(-r, "Failed to check unit: %m");
return r;
}
@@ -2807,13 +2807,13 @@ static int start_unit(sd_bus *bus, char **args) {
else {
r = expand_names(bus, args + 1, suffix, &names);
if (r < 0)
- log_error("Failed to expand names: %s", strerror(-r));
+ log_error_errno(-r, "Failed to expand names: %m");
}
if (!arg_no_block) {
r = enable_wait_for_jobs(bus);
if (r < 0) {
- log_error("Could not watch jobs: %s", strerror(-r));
+ log_error_errno(-r, "Could not watch jobs: %m");
return r;
}
@@ -3075,7 +3075,7 @@ static int check_unit_generic(sd_bus *bus, int code, const char *good_states, ch
r = expand_names(bus, args, NULL, &names);
if (r < 0) {
- log_error("Failed to expand names: %s", strerror(-r));
+ log_error_errno(-r, "Failed to expand names: %m");
return r;
}
@@ -3115,7 +3115,7 @@ static int kill_unit(sd_bus *bus, char **args) {
r = expand_names(bus, args + 1, NULL, &names);
if (r < 0)
- log_error("Failed to expand names: %s", strerror(-r));
+ log_error_errno(-r, "Failed to expand names: %m");
STRV_FOREACH(name, names) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
@@ -4439,7 +4439,7 @@ static int show_system_status(sd_bus *bus) {
r = bus_map_all_properties(bus, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", machine_info_property_map, &mi);
if (r < 0) {
- log_error("Failed to read server status: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read server status: %m");
return r;
}
@@ -4558,7 +4558,7 @@ static int show(sd_bus *bus, char **args) {
r = expand_names(bus, patterns, NULL, &names);
if (r < 0)
- log_error("Failed to expand names: %s", strerror(-r));
+ log_error_errno(-r, "Failed to expand names: %m");
STRV_FOREACH(name, names) {
_cleanup_free_ char *unit;
@@ -4594,7 +4594,7 @@ static int cat(sd_bus *bus, char **args) {
r = expand_names(bus, args + 1, NULL, &names);
if (r < 0)
- log_error("Failed to expand names: %s", strerror(-r));
+ log_error_errno(-r, "Failed to expand names: %m");
pager_open_if_enabled();
@@ -4652,7 +4652,7 @@ static int cat(sd_bus *bus, char **args) {
r = copy_file_fd(fragment_path, STDOUT_FILENO);
if (r < 0) {
- log_warning("Failed to cat %s: %s", fragment_path, strerror(-r));
+ log_warning_errno(-r, "Failed to cat %s: %m", fragment_path);
continue;
}
}
@@ -4667,7 +4667,7 @@ static int cat(sd_bus *bus, char **args) {
r = copy_file_fd(*path, STDOUT_FILENO);
if (r < 0) {
- log_warning("Failed to cat %s: %s", *path, strerror(-r));
+ log_warning_errno(-r, "Failed to cat %s: %m", *path);
continue;
}
}
@@ -4807,7 +4807,7 @@ static int delete_snapshot(sd_bus *bus, char **args) {
r = expand_names(bus, args + 1, ".snapshot", &names);
if (r < 0)
- log_error("Failed to expand names: %s", strerror(-r));
+ log_error_errno(-r, "Failed to expand names: %m");
STRV_FOREACH(name, names) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
@@ -4908,7 +4908,7 @@ static int reset_failed(sd_bus *bus, char **args) {
r = expand_names(bus, args + 1, NULL, &names);
if (r < 0)
- log_error("Failed to expand names: %s", strerror(-r));
+ log_error_errno(-r, "Failed to expand names: %m");
STRV_FOREACH(name, names) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
@@ -5002,7 +5002,7 @@ static int switch_root(sd_bus *bus, char **args) {
"init", &cmdline_init,
NULL);
if (r < 0)
- log_debug("Failed to parse /proc/cmdline: %s", strerror(-r));
+ log_debug_errno(-r, "Failed to parse /proc/cmdline: %m");
init = cmdline_init;
}
@@ -5247,7 +5247,7 @@ static int enable_sysv_units(const char *verb, char **args) {
j = wait_for_terminate(pid, &status);
if (j < 0) {
- log_error("Failed to wait for child: %s", strerror(-r));
+ log_error_errno(-r, "Failed to wait for child: %m");
return j;
}
@@ -5361,7 +5361,7 @@ static int enable_unit(sd_bus *bus, char **args) {
assert_not_reached("Unknown verb");
if (r < 0) {
- log_error("Operation failed: %s", strerror(-r));
+ log_error_errno(-r, "Operation failed: %m");
goto finish;
}
@@ -5510,7 +5510,7 @@ static int add_dependency(sd_bus *bus, char **args) {
r = unit_file_add_dependency(arg_scope, arg_runtime, arg_root, names, target, dep, arg_force, &changes, &n_changes);
if (r < 0) {
- log_error("Can't add dependency: %s", strerror(-r));
+ log_error_errno(-r, "Can't add dependency: %m");
return r;
}
@@ -5573,7 +5573,7 @@ static int preset_all(sd_bus *bus, char **args) {
r = unit_file_preset_all(arg_scope, arg_runtime, arg_root, arg_preset_mode, arg_force, &changes, &n_changes);
if (r < 0) {
- log_error("Operation failed: %s", strerror(-r));
+ log_error_errno(-r, "Operation failed: %m");
goto finish;
}
@@ -5656,7 +5656,7 @@ static int unit_is_enabled(sd_bus *bus, char **args) {
state = unit_file_get_state(arg_scope, arg_root, *name);
if (state < 0) {
- log_error("Failed to get unit file state for %s: %s", *name, strerror(-state));
+ log_error_errno(-state, "Failed to get unit file state for %s: %m", *name);
return state;
}
@@ -6897,7 +6897,7 @@ found:
* enable/disable */
if (verb->bus == NOBUS) {
if (!bus && !avoid_bus()) {
- log_error("Failed to get D-Bus connection: %s", strerror(-bus_error));
+ log_error_errno(-bus_error, "Failed to get D-Bus connection: %m");
return -EIO;
}
@@ -6908,7 +6908,7 @@ found:
}
if ((verb->bus != FORCE || arg_force <= 0) && !bus) {
- log_error("Failed to get D-Bus connection: %s", strerror(-bus_error));
+ log_error_errno(-bus_error, "Failed to get D-Bus connection: %m");
return -EIO;
}
}
@@ -7086,7 +7086,7 @@ static int halt_main(sd_bus *bus) {
m);
if (r < 0)
- log_warning("Failed to talk to shutdownd, proceeding with immediate shutdown: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to talk to shutdownd, proceeding with immediate shutdown: %m");
else {
char date[FORMAT_TIMESTAMP_MAX];
@@ -7105,7 +7105,7 @@ static int halt_main(sd_bus *bus) {
else {
r = utmp_put_shutdown();
if (r < 0)
- log_warning("Failed to write utmp record: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to write utmp record: %m");
}
}
@@ -7113,7 +7113,7 @@ static int halt_main(sd_bus *bus) {
return 0;
r = halt_now(arg_action);
- log_error("Failed to reboot: %s", strerror(-r));
+ log_error_errno(-r, "Failed to reboot: %m");
return r;
}
@@ -7211,7 +7211,7 @@ int main(int argc, char*argv[]) {
r = send_shutdownd(arg_when, SD_SHUTDOWN_NONE, false, !arg_no_wall, m);
if (r < 0)
- log_warning("Failed to talk to shutdownd, shutdown hasn't been cancelled: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to talk to shutdownd, shutdown hasn't been cancelled: %m");
break;
}
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index 7820e84983..89a44f413c 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -920,7 +920,7 @@ static int add_user(Item *i) {
if (i->uid_set) {
r = uid_is_ok(i->uid, i->name);
if (r < 0) {
- log_error("Failed to verify uid " UID_FMT ": %s", i->uid, strerror(-r));
+ log_error_errno(-r, "Failed to verify uid " UID_FMT ": %m", i->uid);
return r;
}
if (r == 0) {
@@ -940,7 +940,7 @@ static int add_user(Item *i) {
else {
r = uid_is_ok(c, i->name);
if (r < 0) {
- log_error("Failed to verify uid " UID_FMT ": %s", i->uid, strerror(-r));
+ log_error_errno(-r, "Failed to verify uid " UID_FMT ": %m", i->uid);
return r;
} else if (r > 0) {
i->uid = c;
@@ -955,7 +955,7 @@ static int add_user(Item *i) {
if (!i->uid_set && i->gid_set) {
r = uid_is_ok((uid_t) i->gid, i->name);
if (r < 0) {
- log_error("Failed to verify uid " UID_FMT ": %s", i->uid, strerror(-r));
+ log_error_errno(-r, "Failed to verify uid " UID_FMT ": %m", i->uid);
return r;
}
if (r > 0) {
@@ -975,7 +975,7 @@ static int add_user(Item *i) {
r = uid_is_ok(search_uid, i->name);
if (r < 0) {
- log_error("Failed to verify uid " UID_FMT ": %s", i->uid, strerror(-r));
+ log_error_errno(-r, "Failed to verify uid " UID_FMT ": %m", i->uid);
return r;
} else if (r > 0)
break;
@@ -1072,7 +1072,7 @@ static int add_group(Item *i) {
if (i->gid_set) {
r = gid_is_ok(i->gid);
if (r < 0) {
- log_error("Failed to verify gid " GID_FMT ": %s", i->gid, strerror(-r));
+ log_error_errno(-r, "Failed to verify gid " GID_FMT ": %m", i->gid);
return r;
}
if (r == 0) {
@@ -1085,7 +1085,7 @@ static int add_group(Item *i) {
if (!i->gid_set && i->uid_set) {
r = gid_is_ok((gid_t) i->uid);
if (r < 0) {
- log_error("Failed to verify gid " GID_FMT ": %s", i->gid, strerror(-r));
+ log_error_errno(-r, "Failed to verify gid " GID_FMT ": %m", i->gid);
return r;
}
if (r > 0) {
@@ -1105,7 +1105,7 @@ static int add_group(Item *i) {
else {
r = gid_is_ok(c);
if (r < 0) {
- log_error("Failed to verify gid " GID_FMT ": %s", i->gid, strerror(-r));
+ log_error_errno(-r, "Failed to verify gid " GID_FMT ": %m", i->gid);
return r;
} else if (r > 0) {
i->gid = c;
@@ -1128,7 +1128,7 @@ static int add_group(Item *i) {
r = gid_is_ok(search_uid);
if (r < 0) {
- log_error("Failed to verify gid " GID_FMT ": %s", i->gid, strerror(-r));
+ log_error_errno(-r, "Failed to verify gid " GID_FMT ": %m", i->gid);
return r;
} else if (r > 0)
break;
@@ -1721,7 +1721,7 @@ static int read_config_file(const char *fn, bool ignore_enoent) {
if (ignore_enoent && r == -ENOENT)
return 0;
- log_error("Failed to open '%s', ignoring: %s", fn, strerror(-r));
+ log_error_errno(-r, "Failed to open '%s', ignoring: %m", fn);
return r;
}
@@ -1853,7 +1853,7 @@ int main(int argc, char *argv[]) {
r = mac_selinux_init(NULL);
if (r < 0) {
- log_error("SELinux setup failed: %s", strerror(-r));
+ log_error_errno(-r, "SELinux setup failed: %m");
goto finish;
}
@@ -1871,7 +1871,7 @@ int main(int argc, char *argv[]) {
r = conf_files_list_nulstr(&files, ".conf", arg_root, conf_file_dirs);
if (r < 0) {
- log_error("Failed to enumerate sysusers.d files: %s", strerror(-r));
+ log_error_errno(-r, "Failed to enumerate sysusers.d files: %m");
goto finish;
}
@@ -1897,19 +1897,19 @@ int main(int argc, char *argv[]) {
lock = take_password_lock(arg_root);
if (lock < 0) {
- log_error("Failed to take lock: %s", strerror(-lock));
+ log_error_errno(-lock, "Failed to take lock: %m");
goto finish;
}
r = load_user_database();
if (r < 0) {
- log_error("Failed to load user database: %s", strerror(-r));
+ log_error_errno(-r, "Failed to load user database: %m");
goto finish;
}
r = load_group_database();
if (r < 0) {
- log_error("Failed to read group database: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read group database: %m");
goto finish;
}
@@ -1921,7 +1921,7 @@ int main(int argc, char *argv[]) {
r = write_files();
if (r < 0)
- log_error("Failed to write files: %s", strerror(-r));
+ log_error_errno(-r, "Failed to write files: %m");
finish:
while ((i = hashmap_steal_first(groups)))
diff --git a/src/test/test-boot-timestamps.c b/src/test/test-boot-timestamps.c
index 4ede318e38..354307cba1 100644
--- a/src/test/test-boot-timestamps.c
+++ b/src/test/test-boot-timestamps.c
@@ -37,7 +37,7 @@ static int test_acpi_fpdt(void) {
r = acpi_get_boot_usec(&loader_start, &loader_exit);
if (r < 0) {
if (r != -ENOENT)
- log_error("Failed to read ACPI FPDT: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read ACPI FPDT: %m");
return r;
}
@@ -60,7 +60,7 @@ static int test_efi_loader(void) {
r = efi_loader_get_boot_usec(&loader_start, &loader_exit);
if (r < 0) {
if (r != -ENOENT)
- log_error("Failed to read EFI loader data: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read EFI loader data: %m");
return r;
}
@@ -84,7 +84,7 @@ int main(int argc, char* argv[]) {
r = boot_timestamps(NULL, &fw, &l);
if (r < 0) {
- log_error("Failed to read variables: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read variables: %m");
return 1;
}
diff --git a/src/test/test-ns.c b/src/test/test-ns.c
index 7714e49ad9..fa297f9183 100644
--- a/src/test/test-ns.c
+++ b/src/test/test-ns.c
@@ -65,7 +65,7 @@ int main(int argc, char *argv[]) {
PROTECT_SYSTEM_NO,
0);
if (r < 0) {
- log_error("Failed to setup namespace: %s", strerror(-r));
+ log_error_errno(-r, "Failed to setup namespace: %m");
return 1;
}
diff --git a/src/test/test-socket-util.c b/src/test/test-socket-util.c
index c2c728bcde..d268423cc4 100644
--- a/src/test/test-socket-util.c
+++ b/src/test/test-socket-util.c
@@ -258,7 +258,7 @@ static void test_nameinfo_pretty(void) {
_cleanup_close_ int sfd = -1, cfd = -1;
r = getnameinfo_pretty(STDIN_FILENO, &stdin_name);
- log_info("No connection remote: %s", strerror(-r));
+ log_info_errno(-r, "No connection remote: %m");
assert_se(r < 0);
diff --git a/src/test/test-watchdog.c b/src/test/test-watchdog.c
index ccb1854708..72e0c03dd7 100644
--- a/src/test/test-watchdog.c
+++ b/src/test/test-watchdog.c
@@ -35,13 +35,13 @@ int main(int argc, char *argv[]) {
r = watchdog_set_timeout(&t);
if (r < 0)
- log_warning("Failed to open watchdog: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to open watchdog: %m");
for (i = 0; i < 5; i++) {
log_info("Pinging...");
r = watchdog_ping();
if (r < 0)
- log_warning("Failed to ping watchdog: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to ping watchdog: %m");
usleep(t/2);
}
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
index 0ba32d31c4..f8d2af97d4 100644
--- a/src/timedate/timedatectl.c
+++ b/src/timedate/timedatectl.c
@@ -232,7 +232,7 @@ static int show_status(sd_bus *bus, char **args, unsigned n) {
map,
&info);
if (r < 0) {
- log_error("Failed to query server: %s", strerror(-r));
+ log_error_errno(-r, "Failed to query server: %m");
goto fail;
}
@@ -364,7 +364,7 @@ static int list_timezones(sd_bus *bus, char **args, unsigned n) {
r = get_timezones(&zones);
if (r < 0) {
- log_error("Failed to read list of time zones: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read list of time zones: %m");
return r;
}
@@ -558,7 +558,7 @@ int main(int argc, char *argv[]) {
r = bus_open_transport(arg_transport, arg_host, false, &bus);
if (r < 0) {
- log_error("Failed to create bus connection: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create bus connection: %m");
goto finish;
}
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 4af054e6b0..5391f5b18f 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -74,7 +74,7 @@ static int context_read_data(Context *c) {
if (r == -EINVAL)
log_warning("/etc/localtime should be a symbolic link to a time zone data file in /usr/share/zoneinfo/.");
else
- log_warning("Failed to get target of /etc/localtime: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to get target of /etc/localtime: %m");
} else {
const char *e;
@@ -411,7 +411,7 @@ static int method_set_timezone(sd_bus *bus, sd_bus_message *m, void *userdata, s
/* 1. Write new configuration file */
r = context_write_data_timezone(c);
if (r < 0) {
- log_error("Failed to set time zone: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set time zone: %m");
return sd_bus_error_set_errnof(error, r, "Failed to set time zone: %s", strerror(-r));
}
@@ -467,7 +467,7 @@ static int method_set_local_rtc(sd_bus *bus, sd_bus_message *m, void *userdata,
/* 1. Write new configuration file */
r = context_write_data_local_rtc(c);
if (r < 0) {
- log_error("Failed to set RTC to local/UTC: %s", strerror(-r));
+ log_error_errno(-r, "Failed to set RTC to local/UTC: %m");
return sd_bus_error_set_errnof(error, r, "Failed to set RTC to local/UTC: %s", strerror(-r));
}
@@ -650,25 +650,25 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
r = sd_bus_default_system(&bus);
if (r < 0) {
- log_error("Failed to get system bus connection: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get system bus connection: %m");
return r;
}
r = sd_bus_add_object_vtable(bus, NULL, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", timedate_vtable, c);
if (r < 0) {
- log_error("Failed to register object: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register object: %m");
return r;
}
r = sd_bus_request_name(bus, "org.freedesktop.timedate1", 0);
if (r < 0) {
- log_error("Failed to register name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register name: %m");
return r;
}
r = sd_bus_attach_event(bus, event, 0);
if (r < 0) {
- log_error("Failed to attach bus to event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to attach bus to event loop: %m");
return r;
}
@@ -698,7 +698,7 @@ int main(int argc, char *argv[]) {
r = sd_event_default(&event);
if (r < 0) {
- log_error("Failed to allocate event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate event loop: %m");
goto finish;
}
@@ -710,19 +710,19 @@ int main(int argc, char *argv[]) {
r = context_read_data(&context);
if (r < 0) {
- log_error("Failed to read time zone data: %s", strerror(-r));
+ log_error_errno(-r, "Failed to read time zone data: %m");
goto finish;
}
r = context_read_ntp(&context, bus);
if (r < 0) {
- log_error("Failed to determine whether NTP is enabled: %s", strerror(-r));
+ log_error_errno(-r, "Failed to determine whether NTP is enabled: %m");
goto finish;
}
r = bus_event_loop_with_idle(event, bus, "org.freedesktop.timedate1", DEFAULT_EXIT_USEC, NULL, NULL);
if (r < 0) {
- log_error("Failed to run event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to run event loop: %m");
goto finish;
}
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
index 03cfb248c0..f87722ddce 100644
--- a/src/timesync/timesyncd-manager.c
+++ b/src/timesync/timesyncd-manager.c
@@ -188,7 +188,7 @@ static int manager_send_request(Manager *m) {
if (m->server_socket < 0) {
r = manager_listen_setup(m);
if (r < 0) {
- log_warning("Failed to setup connection socket: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to setup connection socket: %m");
return r;
}
}
@@ -226,7 +226,7 @@ static int manager_send_request(Manager *m) {
r = manager_arm_timer(m, m->retry_interval);
if (r < 0) {
- log_error("Failed to rearm timer: %s", strerror(-r));
+ log_error_errno(-r, "Failed to rearm timer: %m");
return r;
}
@@ -239,7 +239,7 @@ static int manager_send_request(Manager *m) {
now(clock_boottime_or_monotonic()) + TIMEOUT_USEC, 0,
manager_timeout, m);
if (r < 0) {
- log_error("Failed to arm timeout timer: %s", strerror(-r));
+ log_error_errno(-r, "Failed to arm timeout timer: %m");
return r;
}
}
@@ -329,7 +329,7 @@ static int manager_clock_watch_setup(Manager *m) {
r = sd_event_add_io(m->event, &m->event_clock_watch, m->clock_watch_fd, EPOLLIN, manager_clock_watch, m);
if (r < 0) {
- log_error("Failed to create clock watch event source: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create clock watch event source: %m");
return r;
}
@@ -699,7 +699,7 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
r = manager_arm_timer(m, m->poll_interval_usec);
if (r < 0) {
- log_error("Failed to rearm timer: %s", strerror(-r));
+ log_error_errno(-r, "Failed to rearm timer: %m");
return r;
}
@@ -827,7 +827,7 @@ static int manager_resolve_handler(sd_resolve_query *q, int ret, const struct ad
r = server_address_new(m->current_server_name, &a, (const union sockaddr_union*) ai->ai_addr, ai->ai_addrlen);
if (r < 0) {
- log_error("Failed to add server address: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add server address: %m");
return r;
}
@@ -868,7 +868,7 @@ int manager_connect(Manager *m) {
r = sd_event_add_time(m->event, &m->event_retry, clock_boottime_or_monotonic(), now(clock_boottime_or_monotonic()) + RETRY_USEC, 0, manager_retry_connect, m);
if (r < 0) {
- log_error("Failed to create retry timer: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create retry timer: %m");
return r;
}
@@ -924,7 +924,7 @@ int manager_connect(Manager *m) {
log_debug("Waiting after exhausting servers.");
r = sd_event_add_time(m->event, &m->event_retry, clock_boottime_or_monotonic(), now(clock_boottime_or_monotonic()) + m->poll_interval_usec, 0, manager_retry_connect, m);
if (r < 0) {
- log_error("Failed to create retry timer: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create retry timer: %m");
return r;
}
@@ -953,7 +953,7 @@ int manager_connect(Manager *m) {
r = sd_resolve_getaddrinfo(m->resolve, &m->resolve_query, m->current_server_name->string, "123", &hints, manager_resolve_handler, m);
if (r < 0) {
- log_error("Failed to create resolver: %s", strerror(-r));
+ log_error_errno(-r, "Failed to create resolver: %m");
return r;
}
diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c
index ee3bc99ae0..b5a521f672 100644
--- a/src/timesync/timesyncd.c
+++ b/src/timesync/timesyncd.c
@@ -101,7 +101,7 @@ int main(int argc, char *argv[]) {
r = get_user_creds(&user, &uid, &gid, NULL, NULL);
if (r < 0) {
- log_error("Cannot resolve user name %s: %s", user, strerror(-r));
+ log_error_errno(-r, "Cannot resolve user name %s: %m", user);
goto finish;
}
@@ -117,7 +117,7 @@ int main(int argc, char *argv[]) {
r = manager_new(&m);
if (r < 0) {
- log_error("Failed to allocate manager: %s", strerror(-r));
+ log_error_errno(-r, "Failed to allocate manager: %m");
goto finish;
}
@@ -129,7 +129,7 @@ int main(int argc, char *argv[]) {
r = manager_parse_config_file(m);
if (r < 0)
- log_warning("Failed to parse configuration file: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to parse configuration file: %m");
log_debug("systemd-timesyncd running as pid %lu", (unsigned long) getpid());
sd_notify(false,
@@ -144,7 +144,7 @@ int main(int argc, char *argv[]) {
r = sd_event_loop(m->event);
if (r < 0) {
- log_error("Failed to run event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to run event loop: %m");
goto finish;
}
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 23fd6ca3bc..c44dcff514 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -668,7 +668,7 @@ static int create_item(Item *i) {
struct stat a, b;
if (r != -EEXIST) {
- log_error("Failed to copy files to %s: %s", i->path, strerror(-r));
+ log_error_errno(-r, "Failed to copy files to %s: %m", i->path);
return -r;
}
@@ -711,7 +711,7 @@ static int create_item(Item *i) {
if (r < 0) {
if (r != -EEXIST) {
- log_error("Failed to create directory %s: %s", i->path, strerror(-r));
+ log_error_errno(-r, "Failed to create directory %s: %m", i->path);
return r;
}
@@ -762,7 +762,7 @@ static int create_item(Item *i) {
}
if (r < 0) {
- log_error("Failed to create fifo %s: %s", i->path, strerror(-r));
+ log_error_errno(-r, "Failed to create fifo %s: %m", i->path);
return r;
}
} else {
@@ -801,7 +801,7 @@ static int create_item(Item *i) {
mac_selinux_create_file_clear();
if (r < 0) {
- log_error("symlink(%s, %s) failed: %s", i->argument, i->path, strerror(-r));
+ log_error_errno(-r, "symlink(%s, %s) failed: %m", i->argument, i->path);
return r;
}
} else {
@@ -863,7 +863,7 @@ static int create_item(Item *i) {
}
if (r < 0) {
- log_error("Failed to create device node %s: %s", i->path, strerror(-r));
+ log_error_errno(-r, "Failed to create device node %s: %m", i->path);
return r;
}
} else {
@@ -939,7 +939,7 @@ static int remove_item_instance(Item *i, const char *instance) {
* instead of rm_rf() so that 'x' is honoured. */
r = rm_rf_dangerous(instance, false, i->type == RECURSIVE_REMOVE_PATH, false);
if (r < 0 && r != -ENOENT) {
- log_error("rm_rf(%s): %s", instance, strerror(-r));
+ log_error_errno(-r, "rm_rf(%s): %m", instance);
return r;
}
@@ -1398,7 +1398,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
r = hashmap_put(h, i->path, i);
if (r < 0) {
- log_error("Failed to insert item %s: %s", i->path, strerror(-r));
+ log_error_errno(-r, "Failed to insert item %s: %m", i->path);
return r;
}
@@ -1531,7 +1531,7 @@ static int read_config_file(const char *fn, bool ignore_enoent) {
if (ignore_enoent && r == -ENOENT)
return 0;
- log_error("Failed to open '%s', ignoring: %s", fn, strerror(-r));
+ log_error_errno(-r, "Failed to open '%s', ignoring: %m", fn);
return r;
}
@@ -1629,7 +1629,7 @@ int main(int argc, char *argv[]) {
r = conf_files_list_nulstr(&files, ".conf", arg_root, conf_file_dirs);
if (r < 0) {
- log_error("Failed to enumerate tmpfiles.d files: %s", strerror(-r));
+ log_error_errno(-r, "Failed to enumerate tmpfiles.d files: %m");
goto finish;
}
diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c
index e6dc84b440..70ad3cb1ac 100644
--- a/src/tty-ask-password-agent/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
@@ -339,7 +339,7 @@ static int parse_password(const char *filename, char **wall) {
return 0;
if (r < 0) {
- log_error("Failed to query password: %s", strerror(-r));
+ log_error_errno(-r, "Failed to query password: %m");
return r;
}
@@ -504,7 +504,7 @@ static int watch_passwords(void) {
for (;;) {
r = show_passwords();
if (r < 0)
- log_error("Failed to show password: %s", strerror(-r));
+ log_error_errno(-r, "Failed to show password: %m");
if (poll(pollfd, _FD_MAX, -1) < 0) {
if (errno == EINTR)
@@ -642,7 +642,7 @@ int main(int argc, char *argv[]) {
r = show_passwords();
if (r < 0)
- log_error("Error: %s", strerror(-r));
+ log_error_errno(-r, "Error: %m");
finish:
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
diff --git a/src/udev/net/ethtool-util.c b/src/udev/net/ethtool-util.c
index 54cb928091..e46d4d3d7c 100644
--- a/src/udev/net/ethtool-util.c
+++ b/src/udev/net/ethtool-util.c
@@ -76,7 +76,7 @@ int ethtool_get_driver(int *fd, const char *ifname, char **ret) {
if (*fd < 0) {
r = ethtool_connect(fd);
if (r < 0) {
- log_warning("link_config: could not connect to ethtool: %s", strerror(-r));
+ log_warning_errno(-r, "link_config: could not connect to ethtool: %m");
return r;
}
}
@@ -112,7 +112,7 @@ int ethtool_set_speed(int *fd, const char *ifname, unsigned int speed, Duplex du
if (*fd < 0) {
r = ethtool_connect(fd);
if (r < 0) {
- log_warning("link_config: could not connect to ethtool: %s", strerror(-r));
+ log_warning_errno(-r, "link_config: could not connect to ethtool: %m");
return r;
}
}
@@ -172,7 +172,7 @@ int ethtool_set_wol(int *fd, const char *ifname, WakeOnLan wol) {
if (*fd < 0) {
r = ethtool_connect(fd);
if (r < 0) {
- log_warning("link_config: could not connect to ethtool: %s", strerror(-r));
+ log_warning_errno(-r, "link_config: could not connect to ethtool: %m");
return r;
}
}
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index 5aefb7d415..97e260baed 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -175,7 +175,7 @@ static bool enable_name_policy(void) {
r = proc_cmdline(&line);
if (r < 0) {
- log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to read /proc/cmdline, ignoring: %m");
return true;
}
@@ -203,7 +203,7 @@ int link_config_load(link_config_ctx *ctx) {
r = conf_files_list_strv(&files, ".link", NULL, link_dirs);
if (r < 0) {
- log_error("failed to enumerate link files: %s", strerror(-r));
+ log_error_errno(-r, "failed to enumerate link files: %m");
return r;
}
diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c
index d6b7dbbac0..6628ac873f 100644
--- a/src/udev/udev-builtin-keyboard.c
+++ b/src/udev/udev-builtin-keyboard.c
@@ -62,7 +62,7 @@ static int install_force_release(struct udev_device *dev, const unsigned int *re
log_debug("keyboard: updating force-release list with '%s'", codes);
ret = udev_device_set_sysattr_value(atkbd, "force_release", codes);
if (ret < 0)
- log_error("Error writing force-release attribute: %s", strerror(-ret));
+ log_error_errno(-ret, "Error writing force-release attribute: %m");
return ret;
}
diff --git a/src/udev/udev-builtin-net_setup_link.c b/src/udev/udev-builtin-net_setup_link.c
index 14351de6a6..a1934f463e 100644
--- a/src/udev/udev-builtin-net_setup_link.c
+++ b/src/udev/udev-builtin-net_setup_link.c
@@ -46,14 +46,14 @@ static int builtin_net_setup_link(struct udev_device *dev, int argc, char **argv
log_debug("No matching link configuration found.");
return EXIT_SUCCESS;
} else {
- log_error("Could not get link config: %s", strerror(-r));
+ log_error_errno(-r, "Could not get link config: %m");
return EXIT_FAILURE;
}
}
r = link_config_apply(ctx, link, dev, &name);
if (r < 0) {
- log_error("Could not apply link config to %s: %s", udev_device_get_sysname(dev), strerror(-r));
+ log_error_errno(-r, "Could not apply link config to %s: %m", udev_device_get_sysname(dev));
return EXIT_FAILURE;
}
diff --git a/src/udev/udev-builtin-uaccess.c b/src/udev/udev-builtin-uaccess.c
index 6964fb5529..ecd320a588 100644
--- a/src/udev/udev-builtin-uaccess.c
+++ b/src/udev/udev-builtin-uaccess.c
@@ -63,7 +63,7 @@ static int builtin_uaccess(struct udev_device *dev, int argc, char *argv[], bool
r = devnode_acl(path, true, false, 0, true, uid);
if (r < 0) {
- log_error("Failed to apply ACL on %s: %s", path, strerror(-r));
+ log_error_errno(-r, "Failed to apply ACL on %s: %m", path);
goto finish;
}
@@ -77,7 +77,7 @@ finish:
/* Better be safe than sorry and reset ACL */
k = devnode_acl(path, true, false, 0, false, 0);
if (k < 0) {
- log_error("Failed to apply ACL on %s: %s", path, strerror(-k));
+ log_error_errno(-k, "Failed to apply ACL on %s: %m", path);
if (r >= 0)
r = k;
}
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index 98fd3a9acf..d6cc9b493a 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -194,7 +194,7 @@ struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) {
/* check peer credential of connection */
r = getpeercred(conn->sock, &ucred);
if (r < 0) {
- log_error("unable to receive credentials of ctrl connection: %s", strerror(-r));
+ log_error_errno(-r, "unable to receive credentials of ctrl connection: %m");
goto err;
}
if (ucred.uid > 0) {
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
index 030e459198..f105fa28e2 100644
--- a/src/udev/udev-node.c
+++ b/src/udev/udev-node.c
@@ -304,7 +304,7 @@ static int node_permissions_apply(struct udev_device *dev, bool apply,
r = mac_selinux_apply(devnode, label);
if (r < 0)
- log_error("SECLABEL: failed to set SELinux label '%s': %s", label, strerror(-r));
+ log_error_errno(-r, "SECLABEL: failed to set SELinux label '%s': %m", label);
else
log_debug("SECLABEL: set SELinux label '%s'", label);
@@ -313,7 +313,7 @@ static int node_permissions_apply(struct udev_device *dev, bool apply,
r = mac_smack_apply(devnode, label);
if (r < 0)
- log_error("SECLABEL: failed to set SMACK label '%s': %s", label, strerror(-r));
+ log_error_errno(-r, "SECLABEL: failed to set SMACK label '%s': %m", label);
else
log_debug("SECLABEL: set SMACK label '%s'", label);
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 093d68cf0c..07c1f11033 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -1685,7 +1685,7 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) {
r = conf_files_list_strv(&files, ".rules", NULL, rules_dirs);
if (r < 0) {
- log_error("failed to enumerate rules files: %s", strerror(-r));
+ log_error_errno(-r, "failed to enumerate rules files: %m");
return udev_rules_unref(rules);
}
@@ -2653,7 +2653,7 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) {
strscpyl(tags_dir, sizeof(tags_dir), "/run/udev/static_node-tags/", *t, "/", NULL);
r = mkdir_p(tags_dir, 0755);
if (r < 0) {
- log_error("failed to create %s: %s", tags_dir, strerror(-r));
+ log_error_errno(-r, "failed to create %s: %m", tags_dir);
return r;
}
diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c
index 3ca755e2ed..9a32fa8c6f 100644
--- a/src/udev/udevadm-hwdb.c
+++ b/src/udev/udevadm-hwdb.c
@@ -618,7 +618,7 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) {
err = conf_files_list_strv(&files, ".hwdb", root, conf_file_dirs);
if (err < 0) {
- log_error("failed to enumerate hwdb files: %s", strerror(-err));
+ log_error_errno(-err, "failed to enumerate hwdb files: %m");
rc = EXIT_FAILURE;
goto out;
}
@@ -652,7 +652,7 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) {
mkdir_parents(hwdb_bin, 0755);
err = trie_store(trie, hwdb_bin);
if (err < 0) {
- log_error("Failure writing database %s: %s", hwdb_bin, strerror(-err));
+ log_error_errno(-err, "Failure writing database %s: %m", hwdb_bin);
rc = EXIT_FAILURE;
}
}
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 3c3de76f34..99b033b050 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -962,7 +962,7 @@ static void kernel_cmdline_options(struct udev *udev) {
r = proc_cmdline(&line);
if (r < 0) {
- log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to read /proc/cmdline, ignoring: %m");
return;
}
@@ -1135,7 +1135,7 @@ int main(int argc, char *argv[]) {
r = mac_selinux_init("/dev");
if (r < 0) {
- log_error("could not initialize labelling: %s", strerror(-r));
+ log_error_errno(-r, "could not initialize labelling: %m");
goto exit;
}
@@ -1239,7 +1239,7 @@ int main(int argc, char *argv[]) {
rc = udev_rules_apply_static_dev_perms(rules);
if (rc < 0)
- log_error("failed to apply permissions on static device nodes - %s", strerror(-rc));
+ log_error_errno(-rc, "failed to apply permissions on static device nodes - %m");
if (arg_daemonize) {
pid_t pid;
diff --git a/src/update-done/update-done.c b/src/update-done/update-done.c
index 1437c30d14..07e87b0c08 100644
--- a/src/update-done/update-done.c
+++ b/src/update-done/update-done.c
@@ -114,7 +114,7 @@ int main(int argc, char *argv[]) {
r = mac_selinux_init(NULL);
if (r < 0) {
- log_error("SELinux setup failed: %s", strerror(-r));
+ log_error_errno(-r, "SELinux setup failed: %m");
goto finish;
}
diff --git a/src/update-utmp/update-utmp.c b/src/update-utmp/update-utmp.c
index 311d686a8c..a5dd8a9236 100644
--- a/src/update-utmp/update-utmp.c
+++ b/src/update-utmp/update-utmp.c
@@ -144,7 +144,7 @@ static int on_reboot(Context *c) {
q = utmp_put_reboot(t);
if (q < 0) {
- log_error("Failed to write utmp record: %s", strerror(-q));
+ log_error_errno(-q, "Failed to write utmp record: %m");
r = q;
}
@@ -170,7 +170,7 @@ static int on_shutdown(Context *c) {
q = utmp_put_shutdown();
if (q < 0) {
- log_error("Failed to write utmp record: %s", strerror(-q));
+ log_error_errno(-q, "Failed to write utmp record: %m");
r = q;
}
@@ -190,7 +190,7 @@ static int on_runlevel(Context *c) {
if (q < 0) {
if (q != -ESRCH && q != -ENOENT) {
- log_error("Failed to get current runlevel: %s", strerror(-q));
+ log_error_errno(-q, "Failed to get current runlevel: %m");
return q;
}
@@ -225,7 +225,7 @@ static int on_runlevel(Context *c) {
q = utmp_put_runlevel(runlevel, previous);
if (q < 0 && q != -ESRCH && q != -ENOENT) {
- log_error("Failed to write utmp record: %s", strerror(-q));
+ log_error_errno(-q, "Failed to write utmp record: %m");
r = q;
}
@@ -265,7 +265,7 @@ int main(int argc, char *argv[]) {
#endif
r = bus_open_system_systemd(&c.bus);
if (r < 0) {
- log_error("Failed to get D-Bus connection: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get D-Bus connection: %m");
r = -EIO;
goto finish;
}
diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
index 0db97f88bc..e2ba8a0138 100644
--- a/src/vconsole/vconsole-setup.c
+++ b/src/vconsole/vconsole-setup.c
@@ -62,7 +62,7 @@ static int disable_utf8(int fd) {
r = k;
if (r < 0)
- log_warning("Failed to disable UTF-8: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to disable UTF-8: %m");
return r;
}
@@ -94,7 +94,7 @@ static int enable_utf8(int fd) {
r = k;
if (r < 0)
- log_warning("Failed to enable UTF-8: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to enable UTF-8: %m");
return r;
}
@@ -282,7 +282,7 @@ int main(int argc, char **argv) {
NULL);
if (r < 0 && r != -ENOENT)
- log_warning("Failed to read /etc/vconsole.conf: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to read /etc/vconsole.conf: %m");
/* Let the kernel command line override /etc/vconsole.conf */
if (detect_container(NULL) <= 0) {
@@ -295,7 +295,7 @@ int main(int argc, char **argv) {
NULL);
if (r < 0 && r != -ENOENT)
- log_warning("Failed to read /proc/cmdline: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to read /proc/cmdline: %m");
}
if (utf8)
@@ -305,7 +305,7 @@ int main(int argc, char **argv) {
r = font_load(vc, vc_font, vc_font_map, vc_font_unimap, &font_pid);
if (r < 0) {
- log_error("Failed to start " KBD_SETFONT ": %s", strerror(-r));
+ log_error_errno(-r, "Failed to start " KBD_SETFONT ": %m");
return EXIT_FAILURE;
}
@@ -314,7 +314,7 @@ int main(int argc, char **argv) {
r = keymap_load(vc, vc_keymap, vc_keymap_toggle, utf8, &keymap_pid);
if (r < 0) {
- log_error("Failed to start " KBD_LOADKEYS ": %s", strerror(-r));
+ log_error_errno(-r, "Failed to start " KBD_LOADKEYS ": %m");
return EXIT_FAILURE;
}