diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2014-11-28 19:29:59 +0100 |
---|---|---|
committer | Michal Schmidt <mschmidt@redhat.com> | 2014-11-28 19:49:27 +0100 |
commit | 56f64d95763a799ba4475daf44d8e9f72a1bd474 (patch) | |
tree | 4c38253c718dc1972b811fa7c01ebfa3c2b7776c /src/login | |
parent | 895b3a7b44fe7ca2f260986be2a877ff56a72718 (diff) |
treewide: use log_*_errno whenever %m is in the format string
If the format string contains %m, clearly errno must have a meaningful
value, so we might as well use log_*_errno to have ERRNO= logged.
Using:
find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/'
Plus some whitespace, linewrap, and indent adjustments.
Diffstat (limited to 'src/login')
-rw-r--r-- | src/login/inhibit.c | 4 | ||||
-rw-r--r-- | src/login/logind-button.c | 4 | ||||
-rw-r--r-- | src/login/logind-dbus.c | 4 | ||||
-rw-r--r-- | src/login/logind-session.c | 12 | ||||
-rw-r--r-- | src/login/logind-user.c | 2 | ||||
-rw-r--r-- | src/login/logind.c | 14 | ||||
-rw-r--r-- | src/login/user-sessions.c | 4 |
7 files changed, 22 insertions, 22 deletions
diff --git a/src/login/inhibit.c b/src/login/inhibit.c index db977ccc59..b81cf0f688 100644 --- a/src/login/inhibit.c +++ b/src/login/inhibit.c @@ -266,7 +266,7 @@ int main(int argc, char *argv[]) { pid = fork(); if (pid < 0) { - log_error("Failed to fork: %m"); + log_error_errno(errno, "Failed to fork: %m"); return EXIT_FAILURE; } @@ -276,7 +276,7 @@ int main(int argc, char *argv[]) { close_all_fds(NULL, 0); execvp(argv[optind], argv + optind); - log_error("Failed to execute %s: %m", argv[optind]); + log_error_errno(errno, "Failed to execute %s: %m", argv[optind]); _exit(EXIT_FAILURE); } diff --git a/src/login/logind-button.c b/src/login/logind-button.c index 9c0c6302a9..1afb01fc68 100644 --- a/src/login/logind-button.c +++ b/src/login/logind-button.c @@ -251,12 +251,12 @@ int button_open(Button *b) { b->fd = open(p, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK); if (b->fd < 0) { - log_warning("Failed to open %s: %m", b->name); + log_warning_errno(errno, "Failed to open %s: %m", b->name); return -errno; } if (ioctl(b->fd, EVIOCGNAME(sizeof(name)), name) < 0) { - log_error("Failed to get input name: %m"); + log_error_errno(errno, "Failed to get input name: %m"); r = -errno; goto fail; } diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index d225ba1619..d4123117a3 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -1159,7 +1159,7 @@ static int flush_devices(Manager *m) { d = opendir("/etc/udev/rules.d"); if (!d) { if (errno != ENOENT) - log_warning("Failed to open /etc/udev/rules.d: %m"); + log_warning_errno(errno, "Failed to open /etc/udev/rules.d: %m"); } else { struct dirent *de; @@ -1175,7 +1175,7 @@ static int flush_devices(Manager *m) { continue; if (unlinkat(dirfd(d), de->d_name, 0) < 0) - log_warning("Failed to unlink %s: %m", de->d_name); + log_warning_errno(errno, "Failed to unlink %s: %m", de->d_name); } } diff --git a/src/login/logind-session.c b/src/login/logind-session.c index 5b30457a88..c1800e0854 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -968,7 +968,7 @@ static int session_open_vt(Session *s) { sprintf(path, "/dev/tty%u", s->vtnr); s->vtfd = open(path, O_RDWR | O_CLOEXEC | O_NONBLOCK | O_NOCTTY); if (s->vtfd < 0) { - log_error("cannot open VT %s of session %s: %m", path, s->id); + log_error_errno(errno, "cannot open VT %s of session %s: %m", path, s->id); return -errno; } @@ -989,21 +989,21 @@ int session_prepare_vt(Session *s) { r = fchown(vt, s->user->uid, -1); if (r < 0) { r = -errno; - log_error("Cannot change owner of /dev/tty%u: %m", s->vtnr); + log_error_errno(errno, "Cannot change owner of /dev/tty%u: %m", s->vtnr); goto error; } r = ioctl(vt, KDSKBMODE, K_OFF); if (r < 0) { r = -errno; - log_error("Cannot set K_OFF on /dev/tty%u: %m", s->vtnr); + log_error_errno(errno, "Cannot set K_OFF on /dev/tty%u: %m", s->vtnr); goto error; } r = ioctl(vt, KDSETMODE, KD_GRAPHICS); if (r < 0) { r = -errno; - log_error("Cannot set KD_GRAPHICS on /dev/tty%u: %m", s->vtnr); + log_error_errno(errno, "Cannot set KD_GRAPHICS on /dev/tty%u: %m", s->vtnr); goto error; } @@ -1016,7 +1016,7 @@ int session_prepare_vt(Session *s) { r = ioctl(vt, VT_SETMODE, &mode); if (r < 0) { r = -errno; - log_error("Cannot set VT_PROCESS on /dev/tty%u: %m", s->vtnr); + log_error_errno(errno, "Cannot set VT_PROCESS on /dev/tty%u: %m", s->vtnr); goto error; } @@ -1073,7 +1073,7 @@ void session_leave_vt(Session *s) { session_device_pause_all(s); r = ioctl(s->vtfd, VT_RELDISP, 1); if (r < 0) - log_debug("Cannot release VT of session %s: %m", s->id); + log_debug_errno(errno, "Cannot release VT of session %s: %m", s->id); } bool session_is_controller(Session *s, const char *sender) { diff --git a/src/login/logind-user.c b/src/login/logind-user.c index f865afdb53..9ff1302663 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -511,7 +511,7 @@ static int user_remove_runtime_path(User *u) { 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); + log_error_errno(errno, "Failed to unmount user runtime directory %s: %m", u->runtime_path); r = rm_rf(u->runtime_path, false, true, false); if (r < 0) diff --git a/src/login/logind.c b/src/login/logind.c index 78220ff4dd..b44f376427 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -290,7 +290,7 @@ static int manager_enumerate_seats(Manager *m) { if (errno == ENOENT) return 0; - log_error("Failed to open /run/systemd/seats: %m"); + log_error_errno(errno, "Failed to open /run/systemd/seats: %m"); return -errno; } @@ -327,7 +327,7 @@ static int manager_enumerate_linger_users(Manager *m) { if (errno == ENOENT) return 0; - log_error("Failed to open /var/lib/systemd/linger/: %m"); + log_error_errno(errno, "Failed to open /var/lib/systemd/linger/: %m"); return -errno; } @@ -363,7 +363,7 @@ static int manager_enumerate_users(Manager *m) { if (errno == ENOENT) return 0; - log_error("Failed to open /run/systemd/users: %m"); + log_error_errno(errno, "Failed to open /run/systemd/users: %m"); return -errno; } @@ -404,7 +404,7 @@ static int manager_enumerate_sessions(Manager *m) { if (errno == ENOENT) return 0; - log_error("Failed to open /run/systemd/sessions: %m"); + log_error_errno(errno, "Failed to open /run/systemd/sessions: %m"); return -errno; } @@ -451,7 +451,7 @@ static int manager_enumerate_inhibitors(Manager *m) { if (errno == ENOENT) return 0; - log_error("Failed to open /run/systemd/inhibit: %m"); + log_error_errno(errno, "Failed to open /run/systemd/inhibit: %m"); return -errno; } @@ -568,7 +568,7 @@ static int manager_reserve_vt(Manager *m) { /* Don't complain on VT-less systems */ if (errno != ENOENT) - log_warning("Failed to pin reserved VT: %m"); + log_warning_errno(errno, "Failed to pin reserved VT: %m"); return -errno; } @@ -753,7 +753,7 @@ static int manager_connect_console(Manager *m) { if (errno == ENOENT) return 0; - log_error("Failed to open /sys/class/tty/tty0/active: %m"); + log_error_errno(errno, "Failed to open /sys/class/tty/tty0/active: %m"); return -errno; } diff --git a/src/login/user-sessions.c b/src/login/user-sessions.c index fb0afc5e50..6edb823e8c 100644 --- a/src/login/user-sessions.c +++ b/src/login/user-sessions.c @@ -44,7 +44,7 @@ int main(int argc, char*argv[]) { int r = 0; if (unlink("/run/nologin") < 0 && errno != ENOENT) { - log_error("Failed to remove /run/nologin file: %m"); + log_error_errno(errno, "Failed to remove /run/nologin file: %m"); r = -errno; } @@ -55,7 +55,7 @@ int main(int argc, char*argv[]) { * exist), don't complain */ if (errno != EROFS || access("/etc/nologin", F_OK) >= 0) { - log_error("Failed to remove /etc/nologin file: %m"); + log_error_errno(errno, "Failed to remove /etc/nologin file: %m"); return EXIT_FAILURE; } } |