diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2014-11-28 18:50:43 +0100 |
---|---|---|
committer | Michal Schmidt <mschmidt@redhat.com> | 2014-11-28 18:56:16 +0100 |
commit | f647962d64e844689f3e2acfce6102fc47e76df2 (patch) | |
tree | dcaf5e38de1d4e31f73f540bc85532ceb72cfa6b /src/machine | |
parent | e80733be33e52d8ab2f1ae845326d39c600f5612 (diff) |
treewide: yet more log_*_errno + return simplifications
Using:
find . -name '*.[ch]' | while read f; do perl -i.mmm -e \
'local $/;
local $_=<>;
s/(if\s*\([^\n]+\))\s*{\n(\s*)(log_[a-z_]*_errno\(\s*([->a-zA-Z_]+)\s*,[^;]+);\s*return\s+\g4;\s+}/\1\n\2return \3;/msg;
print;'
$f
done
And a couple of manual whitespace fixups.
Diffstat (limited to 'src/machine')
-rw-r--r-- | src/machine/machinectl.c | 48 | ||||
-rw-r--r-- | src/machine/machined.c | 60 |
2 files changed, 36 insertions, 72 deletions
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index 52cdfda627..6db9e5c91b 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -414,10 +414,8 @@ static int show_info(const char *verb, sd_bus *bus, const char *path, bool *new_ path, map, &info); - if (r < 0) { - log_error_errno(r, "Could not get properties: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not get properties: %m"); if (*new_line) printf("\n"); @@ -681,16 +679,12 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) { } r = sd_event_default(&event); - if (r < 0) { - log_error_errno(r, "Failed to get event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get event loop: %m"); r = sd_bus_attach_event(bus, event, 0); - if (r < 0) { - log_error_errno(r, "Failed to attach bus to event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to attach bus to event loop: %m"); r = sd_bus_call_method( bus, @@ -719,20 +713,16 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) { &error, &reply2, "u"); - if (r < 0) { - log_error_errno(r, "Failed to retrieve PID of leader: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to retrieve PID of leader: %m"); r = sd_bus_message_read(reply2, "u", &leader); if (r < 0) return bus_log_parse_error(r); master = openpt_in_namespace(leader, O_RDWR|O_NOCTTY|O_CLOEXEC|O_NDELAY); - if (master < 0) { - log_error_errno(master, "Failed to acquire pseudo tty: %m"); - return master; - } + if (master < 0) + return log_error_errno(master, "Failed to acquire pseudo tty: %m"); pty = ptsname(master); if (!pty) { @@ -747,10 +737,8 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) { } r = sd_bus_open_system_container(&container_bus, args[1]); - if (r < 0) { - log_error_errno(r, "Failed to get container bus: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get container bus: %m"); getty = strjoin("container-getty@", p, ".service", NULL); if (!getty) @@ -785,16 +773,12 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) { sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL); r = pty_forward_new(event, master, &forward); - if (r < 0) { - log_error_errno(r, "Failed to create PTY forwarder: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create PTY forwarder: %m"); r = sd_event_loop(event); - if (r < 0) { - log_error_errno(r, "Failed to run event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to run event loop: %m"); forward = pty_forward_free(forward); diff --git a/src/machine/machined.c b/src/machine/machined.c index 2385fead6e..d1c10d2a26 100644 --- a/src/machine/machined.c +++ b/src/machine/machined.c @@ -137,28 +137,20 @@ static int manager_connect_bus(Manager *m) { assert(!m->bus); r = sd_bus_default_system(&m->bus); - if (r < 0) { - log_error_errno(r, "Failed to connect to system bus: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to connect to system bus: %m"); r = sd_bus_add_object_vtable(m->bus, NULL, "/org/freedesktop/machine1", "org.freedesktop.machine1.Manager", manager_vtable, m); - if (r < 0) { - log_error_errno(r, "Failed to add manager object vtable: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add manager object vtable: %m"); r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/machine1/machine", "org.freedesktop.machine1.Machine", machine_vtable, machine_object_find, m); - if (r < 0) { - log_error_errno(r, "Failed to add machine object vtable: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add machine object vtable: %m"); r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/machine1/machine", machine_node_enumerator, m); - if (r < 0) { - log_error_errno(r, "Failed to add machine enumerator: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add machine enumerator: %m"); r = sd_bus_add_match(m->bus, NULL, @@ -169,10 +161,8 @@ static int manager_connect_bus(Manager *m) { "path='/org/freedesktop/systemd1'", match_job_removed, m); - if (r < 0) { - log_error_errno(r, "Failed to add match for JobRemoved: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add match for JobRemoved: %m"); r = sd_bus_add_match(m->bus, NULL, @@ -183,10 +173,8 @@ static int manager_connect_bus(Manager *m) { "path='/org/freedesktop/systemd1'", match_unit_removed, m); - if (r < 0) { - log_error_errno(r, "Failed to add match for UnitRemoved: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add match for UnitRemoved: %m"); r = sd_bus_add_match(m->bus, NULL, @@ -196,10 +184,8 @@ static int manager_connect_bus(Manager *m) { "member='PropertiesChanged'", match_properties_changed, m); - if (r < 0) { - log_error_errno(r, "Failed to add match for PropertiesChanged: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add match for PropertiesChanged: %m"); r = sd_bus_add_match(m->bus, NULL, @@ -210,10 +196,8 @@ static int manager_connect_bus(Manager *m) { "path='/org/freedesktop/systemd1'", match_reloading, m); - if (r < 0) { - log_error_errno(r, "Failed to add match for Reloading: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add match for Reloading: %m"); r = sd_bus_call_method( m->bus, @@ -229,16 +213,12 @@ static int manager_connect_bus(Manager *m) { } r = sd_bus_request_name(m->bus, "org.freedesktop.machine1", 0); - if (r < 0) { - log_error_errno(r, "Failed to register name: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register name: %m"); r = sd_bus_attach_event(m->bus, m->event, 0); - if (r < 0) { - log_error_errno(r, "Failed to attach bus to event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to attach bus to event loop: %m"); return 0; } |