diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-04-19 11:28:36 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-04-23 12:23:15 +0200 |
commit | 2abda6d1e4a4f18a6033f865cf83d914a3f27e9e (patch) | |
tree | 43f87cac1304f16febd35f36618ae91ec6d43c5d /src | |
parent | 2caef9fba40069374f7312a7861f2f4ca04edd0b (diff) | |
download | systemd-2abda6d1e4a4f18a6033f865cf83d914a3f27e9e.tar.gz |
sd-bus: use _cleanup_ for struct introspect
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd/sd-bus/bus-objects.c | 41 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-introspect.c | 4 |
2 files changed, 15 insertions, 30 deletions
diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c index 7053471d6d..650cee63af 100644 --- a/src/libsystemd/sd-bus/bus-objects.c +++ b/src/libsystemd/sd-bus/bus-objects.c @@ -894,7 +894,7 @@ static int process_introspect( _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; _cleanup_set_free_free_ Set *s = NULL; const char *previous_interface = NULL; - struct introspect intro; + _cleanup_(introspect_free) struct introspect intro = {}; struct node_vtable *c; bool empty; int r; @@ -925,14 +925,10 @@ static int process_introspect( continue; r = node_vtable_get_userdata(bus, m->path, c, NULL, &error); - if (r < 0) { - r = bus_maybe_reply_error(m, r, &error); - goto finish; - } - if (bus->nodes_modified) { - r = 0; - goto finish; - } + if (r < 0) + return bus_maybe_reply_error(m, r, &error); + if (bus->nodes_modified) + return 0; if (r == 0) continue; @@ -942,7 +938,6 @@ static int process_introspect( continue; if (!streq_ptr(previous_interface, c->interface)) { - if (previous_interface) fputs(" </interface>\n", intro.f); @@ -951,7 +946,7 @@ static int process_introspect( r = introspect_write_interface(&intro, c->vtable); if (r < 0) - goto finish; + return r; previous_interface = c->interface; } @@ -963,35 +958,27 @@ static int process_introspect( /* Nothing?, let's see if we exist at all, and if not * refuse to do anything */ r = bus_node_exists(bus, n, m->path, require_fallback); - if (r <= 0) { - r = bus_maybe_reply_error(m, r, &error); - goto finish; - } - if (bus->nodes_modified) { - r = 0; - goto finish; - } + if (r <= 0) + return bus_maybe_reply_error(m, r, &error); + if (bus->nodes_modified) + return 0; } *found_object = true; r = introspect_write_child_nodes(&intro, s, m->path); if (r < 0) - goto finish; + return r; r = introspect_finish(&intro, bus, m, &reply); if (r < 0) - goto finish; + return r; r = sd_bus_send(bus, reply, NULL); if (r < 0) - goto finish; - - r = 1; + return r; -finish: - introspect_free(&intro); - return r; + return 1; } static int object_manager_serialize_path( diff --git a/src/libsystemd/sd-bus/test-bus-introspect.c b/src/libsystemd/sd-bus/test-bus-introspect.c index 9c8e93e897..968de40e5a 100644 --- a/src/libsystemd/sd-bus/test-bus-introspect.c +++ b/src/libsystemd/sd-bus/test-bus-introspect.c @@ -28,7 +28,7 @@ static const sd_bus_vtable vtable[] = { }; int main(int argc, char *argv[]) { - struct introspect intro; + _cleanup_(introspect_free) struct introspect intro = {}; test_setup_logging(LOG_DEBUG); @@ -41,7 +41,5 @@ int main(int argc, char *argv[]) { fflush(intro.f); fputs(intro.introspection, stdout); - introspect_free(&intro); - return 0; } |