+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
sd_bus_error *error) {
sd_bus_slot *s;
- void *u;
+ void *u, *found_u;
int r;
assert(bus);
if (c->find) {
bus->current_slot = sd_bus_slot_ref(s);
bus->current_userdata = u;
- r = c->find(bus, path, c->interface, u, &u, error);
+ r = c->find(bus, path, c->interface, u, &found_u, error);
bus->current_userdata = NULL;
bus->current_slot = sd_bus_slot_unref(s);
return -sd_bus_error_get_errno(error);
if (r == 0)
return r;
- }
+ } else
+ found_u = u;
if (userdata)
- *userdata = u;
+ *userdata = found_u;
return 1;
}
return 1;
for (v = c->vtable+1; v->type != _SD_BUS_VTABLE_END; v++) {
- if (v->type != _SD_BUS_VTABLE_PROPERTY && v->type != _SD_BUS_VTABLE_WRITABLE_PROPERTY)
+ if (!IN_SET(v->type, _SD_BUS_VTABLE_PROPERTY, _SD_BUS_VTABLE_WRITABLE_PROPERTY))
continue;
if (v->flags & SD_BUS_VTABLE_HIDDEN)
return 0;
}
+ if (!*found_object)
+ return 0;
+
if (!found_interface) {
r = sd_bus_reply_method_errorf(
m,
if (!streq_ptr(previous_interface, c->interface)) {
if (previous_interface)
- fputs(" </interface>\n", intro.f);
+ fputs_unlocked(" </interface>\n", intro.f);
fprintf(intro.f, " <interface name=\"%s\">\n", c->interface);
}
}
if (previous_interface)
- fputs(" </interface>\n", intro.f);
+ fputs_unlocked(" </interface>\n", intro.f);
if (empty) {
/* 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)
+ if (r <= 0) {
+ r = bus_maybe_reply_error(m, r, &error);
goto finish;
+ }
if (bus->nodes_modified) {
r = 0;
goto finish;
r = get_child_nodes(bus, m->path, n, CHILDREN_RECURSIVE, &s, &error);
if (r < 0)
- return r;
+ return bus_maybe_reply_error(m, r, &error);
if (bus->nodes_modified)
return 0;
SET_FOREACH(path, s, i) {
r = object_manager_serialize_path_and_fallbacks(bus, reply, path, &error);
if (r < 0)
- return r;
+ return bus_maybe_reply_error(m, r, &error);
if (bus->nodes_modified)
return 0;
if (!*found_object) {
r = bus_node_exists(bus, n, m->path, require_fallback);
if (r < 0)
- return r;
+ return bus_maybe_reply_error(m, r, NULL);
if (bus->nodes_modified)
return 0;
if (r > 0)
n->object_managers)
return;
- assert(hashmap_remove(b->nodes, n->path) == n);
+ assert_se(hashmap_remove(b->nodes, n->path) == n);
if (n->parent)
LIST_REMOVE(siblings, n->parent->child, n);
goto fail;
}
- /* Fall through */
-
+ _fallthrough_;
case _SD_BUS_VTABLE_PROPERTY: {
struct vtable_member *m;
* as changing in the message. */
for (v = c->vtable+1; v->type != _SD_BUS_VTABLE_END; v++) {
- if (v->type != _SD_BUS_VTABLE_PROPERTY && v->type != _SD_BUS_VTABLE_WRITABLE_PROPERTY)
+ if (!IN_SET(v->type, _SD_BUS_VTABLE_PROPERTY, _SD_BUS_VTABLE_WRITABLE_PROPERTY))
continue;
if (v->flags & SD_BUS_VTABLE_HIDDEN)
const sd_bus_vtable *v;
for (v = c->vtable+1; v->type != _SD_BUS_VTABLE_END; v++) {
- if (v->type != _SD_BUS_VTABLE_PROPERTY && v->type != _SD_BUS_VTABLE_WRITABLE_PROPERTY)
+ if (!IN_SET(v->type, _SD_BUS_VTABLE_PROPERTY, _SD_BUS_VTABLE_WRITABLE_PROPERTY))
continue;
if (v->flags & SD_BUS_VTABLE_HIDDEN)