diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2014-11-28 11:58:34 +0100 |
---|---|---|
committer | Michal Schmidt <mschmidt@redhat.com> | 2014-11-28 12:04:41 +0100 |
commit | 0a1beeb64207eaa88ab9236787b1cbc2f704ae14 (patch) | |
tree | 50117277be2e2078d0373b944a30b4f09bb94443 /src/libsystemd-terminal | |
parent | b4d23205f238e06aaa31264628e20669e714acad (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/libsystemd-terminal')
-rw-r--r-- | src/libsystemd-terminal/evcat.c | 14 | ||||
-rw-r--r-- | src/libsystemd-terminal/idev-keyboard.c | 8 | ||||
-rw-r--r-- | src/libsystemd-terminal/modeset.c | 10 | ||||
-rw-r--r-- | src/libsystemd-terminal/subterm.c | 38 | ||||
-rw-r--r-- | src/libsystemd-terminal/sysview.c | 4 |
5 files changed, 37 insertions, 37 deletions
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; } |