summaryrefslogtreecommitdiff
path: root/src/core
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/core
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/core')
-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
23 files changed, 112 insertions, 112 deletions
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;
}