summaryrefslogtreecommitdiff
path: root/src/libsystemd-terminal
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2014-11-28 18:23:20 +0100
committerMichal Schmidt <mschmidt@redhat.com>2014-11-28 18:24:30 +0100
commit23bbb0de4e3f85d9704a5c12a5afa2dfa0159e41 (patch)
tree28e66fb86dd0cffc3a3cca3cf234cb52c3b64ad3 /src/libsystemd-terminal
parent5e03c6e3b517286bbd65b48d88f60e5b83721894 (diff)
treewide: more log_*_errno + return simplifications
Diffstat (limited to 'src/libsystemd-terminal')
-rw-r--r--src/libsystemd-terminal/evcat.c42
-rw-r--r--src/libsystemd-terminal/idev-keyboard.c17
-rw-r--r--src/libsystemd-terminal/modeset.c30
-rw-r--r--src/libsystemd-terminal/subterm.c37
4 files changed, 43 insertions, 83 deletions
diff --git a/src/libsystemd-terminal/evcat.c b/src/libsystemd-terminal/evcat.c
index b0b1a197ed..b77f4b0f51 100644
--- a/src/libsystemd-terminal/evcat.c
+++ b/src/libsystemd-terminal/evcat.c
@@ -137,16 +137,12 @@ static int evcat_new(Evcat **out) {
return log_oom();
r = sd_pid_get_session(getpid(), &e->session);
- if (r < 0) {
- log_error_errno(r, "Cannot retrieve logind session: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot retrieve logind session: %m");
r = sd_session_get_seat(e->session, &e->seat);
- if (r < 0) {
- log_error_errno(r, "Cannot retrieve seat of logind session: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot retrieve seat of logind session: %m");
e->managed = is_managed(e->session);
@@ -318,17 +314,13 @@ static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *e
name,
evcat_idev_fn,
e);
- if (r < 0) {
- log_error_errno(r, "Cannot create idev session: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot create idev session: %m");
if (e->managed) {
r = sysview_session_take_control(ev->session_add.session);
- if (r < 0) {
- log_error_errno(r, "Cannot request session control: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot request session control: %m");
}
idev_session_enable(e->idev_session);
@@ -345,10 +337,8 @@ static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *e
type = sysview_device_get_type(d);
if (type == SYSVIEW_DEVICE_EVDEV) {
r = idev_session_add_evdev(e->idev_session, sysview_device_get_ud(d));
- if (r < 0) {
- log_error_errno(r, "Cannot add evdev device to idev: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot add evdev device to idev: %m");
}
break;
@@ -357,19 +347,15 @@ static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *e
type = sysview_device_get_type(d);
if (type == SYSVIEW_DEVICE_EVDEV) {
r = idev_session_remove_evdev(e->idev_session, sysview_device_get_ud(d));
- if (r < 0) {
- log_error_errno(r, "Cannot remove evdev device from idev: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot remove evdev device from idev: %m");
}
break;
case SYSVIEW_EVENT_SESSION_CONTROL:
r = ev->session_control.error;
- if (r < 0) {
- log_error_errno(r, "Cannot acquire session control: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot acquire session control: %m");
r = ioctl(1, KDSKBMODE, K_UNICODE);
if (r < 0) {
diff --git a/src/libsystemd-terminal/idev-keyboard.c b/src/libsystemd-terminal/idev-keyboard.c
index bcb2a4b1e2..def8ea5ebe 100644
--- a/src/libsystemd-terminal/idev-keyboard.c
+++ b/src/libsystemd-terminal/idev-keyboard.c
@@ -445,8 +445,7 @@ static int kbdctx_query_locale(kbdctx *kc) {
return 0;
error:
- log_debug_errno(r, "idev-keyboard: cannot send GetAll to locale1: %m");
- return r;
+ return log_debug_errno(r, "idev-keyboard: cannot send GetAll to locale1: %m");
}
static int kbdctx_locale_props_changed_fn(sd_bus *bus,
@@ -477,8 +476,7 @@ static int kbdctx_locale_props_changed_fn(sd_bus *bus,
return 0;
error:
- log_debug_errno(r, "idev-keyboard: cannot handle PropertiesChanged from locale1: %m");
- return r;
+ return log_debug_errno(r, "idev-keyboard: cannot handle PropertiesChanged from locale1: %m");
}
static int kbdctx_setup_bus(kbdctx *kc) {
@@ -493,10 +491,8 @@ static int kbdctx_setup_bus(kbdctx *kc) {
"path='/org/freedesktop/locale1'",
kbdctx_locale_props_changed_fn,
kc);
- if (r < 0) {
- log_debug_errno(r, "idev-keyboard: cannot setup locale1 link: %m");
- return r;
- }
+ if (r < 0)
+ return log_debug_errno(r, "idev-keyboard: cannot setup locale1 link: %m");
return kbdctx_query_locale(kc);
}
@@ -1125,9 +1121,8 @@ static int keyboard_update_kbdmap(idev_keyboard *k) {
return 0;
error:
- log_debug_errno(r, "idev-keyboard: %s/%s: cannot adopt new keymap: %m",
- d->session->name, d->name);
- return r;
+ return log_debug_errno(r, "idev-keyboard: %s/%s: cannot adopt new keymap: %m",
+ d->session->name, d->name);
}
static int keyboard_update_kbdtbl(idev_keyboard *k) {
diff --git a/src/libsystemd-terminal/modeset.c b/src/libsystemd-terminal/modeset.c
index 54faec8fee..0b6499b18f 100644
--- a/src/libsystemd-terminal/modeset.c
+++ b/src/libsystemd-terminal/modeset.c
@@ -146,16 +146,12 @@ static int modeset_new(Modeset **out) {
return log_oom();
r = sd_pid_get_session(getpid(), &m->session);
- if (r < 0) {
- log_error_errno(r, "Cannot retrieve logind session: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot retrieve logind session: %m");
r = sd_session_get_seat(m->session, &m->seat);
- if (r < 0) {
- log_error_errno(r, "Cannot retrieve seat of logind session: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot retrieve seat of logind session: %m");
m->my_tty = is_my_tty(m->session);
m->managed = m->my_tty && geteuid() > 0;
@@ -309,17 +305,13 @@ static int modeset_sysview_fn(sysview_context *c, void *userdata, sysview_event
name,
modeset_grdev_fn,
m);
- if (r < 0) {
- log_error_errno(r, "Cannot create grdev session: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot create grdev session: %m");
if (m->managed) {
r = sysview_session_take_control(ev->session_add.session);
- if (r < 0) {
- log_error_errno(r, "Cannot request session control: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot request session control: %m");
}
grdev_session_enable(m->grdev_session);
@@ -358,10 +350,8 @@ static int modeset_sysview_fn(sysview_context *c, void *userdata, sysview_event
break;
case SYSVIEW_EVENT_SESSION_CONTROL:
r = ev->session_control.error;
- if (r < 0) {
- log_error_errno(r, "Cannot acquire session control: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot acquire session control: %m");
r = ioctl(1, KDSKBMODE, K_UNICODE);
if (r < 0) {
diff --git a/src/libsystemd-terminal/subterm.c b/src/libsystemd-terminal/subterm.c
index 97a98a9843..920b661af4 100644
--- a/src/libsystemd-terminal/subterm.c
+++ b/src/libsystemd-terminal/subterm.c
@@ -125,10 +125,8 @@ static int output_flush(Output *o) {
return 0;
len = loop_write(o->fd, o->obuf, o->n_obuf, false);
- if (len < 0) {
- log_error_errno(len, "error: cannot write to TTY (%zd): %m", len);
- return len;
- }
+ if (len < 0)
+ return log_error_errno(len, "error: cannot write to TTY (%zd): %m", len);
o->n_obuf = 0;
@@ -156,10 +154,8 @@ static int output_write(Output *o, const void *buf, size_t size) {
return r;
len = loop_write(o->fd, buf, size, false);
- if (len < 0) {
- log_error_errno(len, "error: cannot write to TTY (%zd): %m", len);
- return len;
- }
+ if (len < 0)
+ return log_error_errno(len, "error: cannot write to TTY (%zd): %m", len);
return 0;
}
@@ -656,10 +652,8 @@ static int terminal_write_tmp(Terminal *t) {
if (t->pty) {
for (i = 0; i < num; ++i) {
r = pty_write(t->pty, vec[i].iov_base, vec[i].iov_len);
- if (r < 0) {
- log_error_errno(r, "error: cannot write to PTY (%d): %m", r);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "error: cannot write to PTY (%d): %m", r);
}
}
@@ -725,10 +719,8 @@ static int terminal_io_fn(sd_event_source *source, int fd, uint32_t revents, voi
n_str = term_utf8_decode(&t->utf8, &str, buf[i]);
for (j = 0; j < n_str; ++j) {
type = term_parser_feed(t->parser, &seq, str[j]);
- if (type < 0) {
- log_error_errno(type, "error: term_parser_feed() (%d): %m", type);
- return type;
- }
+ if (type < 0)
+ return log_error_errno(type, "error: term_parser_feed() (%d): %m", type);
if (!t->is_menu) {
r = terminal_push_tmp(t, str[j]);
@@ -777,10 +769,8 @@ static int terminal_pty_fn(Pty *pty, void *userdata, unsigned int event, const v
break;
case PTY_DATA:
r = term_screen_feed_text(t->screen, ptr, size);
- if (r < 0) {
- log_error_errno(r, "error: term_screen_feed_text() (%d): %m", r);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "error: term_screen_feed_text() (%d): %m", r);
terminal_dirty(t);
break;
@@ -951,10 +941,9 @@ static int terminal_run(Terminal *t) {
assert_return(t, -EINVAL);
pid = pty_fork(&t->pty, t->event, terminal_pty_fn, t, t->output->in_width, t->output->in_height);
- if (pid < 0) {
- log_error_errno(pid, "error: cannot fork PTY (%d): %m", pid);
- return pid;
- } else if (pid == 0) {
+ if (pid < 0)
+ return log_error_errno(pid, "error: cannot fork PTY (%d): %m", pid);
+ else if (pid == 0) {
/* child */
char **argv = (char*[]){