summaryrefslogtreecommitdiff
path: root/src/login/logind.c
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/login/logind.c
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/login/logind.c')
-rw-r--r--src/login/logind.c70
1 files changed, 35 insertions, 35 deletions
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;
}