X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flibsystemd-bus%2Fsd-bus.c;h=542b5e8c49e6d0c5b6ec8f8992f7d6b7641be112;hb=5a037827f61a2e78f3863bc5a08f1535882d7f6a;hp=b1dcd8dc624fc2e65846429f58cd12fc7d83adbc;hpb=29ddb38fea134c6132e4f2dd608e9da3871eaebe;p=elogind.git diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c index b1dcd8dc6..542b5e8c4 100644 --- a/src/libsystemd-bus/sd-bus.c +++ b/src/libsystemd-bus/sd-bus.c @@ -1887,7 +1887,6 @@ static int node_vtable_get_userdata( assert(bus); assert(path); assert(c); - assert(userdata); u = c->userdata; if (c->find) { @@ -1896,7 +1895,9 @@ static int node_vtable_get_userdata( return r; } - *userdata = u; + if (userdata) + *userdata = u; + return 1; } @@ -2344,8 +2345,8 @@ static bool bus_node_exists(sd_bus *bus, struct node *n, const char *path, bool assert(bus); assert(n); - if (n->child) - return true; + /* Tests if there's anything attached directly to this node + * for the specified path */ LIST_FOREACH(callbacks, k, n->callbacks) { if (require_fallback && !k->is_fallback) @@ -2359,11 +2360,11 @@ static bool bus_node_exists(sd_bus *bus, struct node *n, const char *path, bool if (require_fallback && !c->is_fallback) continue; - return true; + if (node_vtable_get_userdata(bus, path, c, NULL) > 0) + return true; } return !require_fallback && (n->enumerators || n->object_manager); - } static int process_introspect( @@ -2400,12 +2401,10 @@ static int process_introspect( empty = set_isempty(s); LIST_FOREACH(vtables, c, n->vtables) { - void *u; - if (require_fallback && !c->is_fallback) continue; - r = node_vtable_get_userdata(bus, m->path, c, &u); + r = node_vtable_get_userdata(bus, m->path, c, NULL); if (r < 0) return r; if (r == 0) @@ -2500,6 +2499,7 @@ static int object_manager_serialize_vtable( static int object_manager_serialize_path( sd_bus *bus, sd_bus_message *reply, + const char *prefix, const char *path, bool require_fallback, sd_bus_error *error) { @@ -2510,10 +2510,11 @@ static int object_manager_serialize_path( assert(bus); assert(reply); + assert(prefix); assert(path); assert(error); - n = hashmap_get(bus->nodes, path); + n = hashmap_get(bus->nodes, prefix); if (!n) return 0; @@ -2567,7 +2568,7 @@ static int object_manager_serialize_path_and_fallbacks( assert(error); /* First, add all vtables registered for this path */ - r = object_manager_serialize_path(bus, reply, path, false, error); + r = object_manager_serialize_path(bus, reply, path, path, false, error); if (r < 0) return r; if (sd_bus_error_is_set(error)) @@ -2588,7 +2589,7 @@ static int object_manager_serialize_path_and_fallbacks( *e = 0; - r = object_manager_serialize_path(bus, reply, p, true, error); + r = object_manager_serialize_path(bus, reply, p, path, true, error); if (r < 0) return r; @@ -2688,7 +2689,13 @@ static int process_get_managed_objects( return 1; } -static int object_find_and_run(sd_bus *bus, sd_bus_message *m, const char *p, bool require_fallback, bool *found_object) { +static int object_find_and_run( + sd_bus *bus, + sd_bus_message *m, + const char *p, + bool require_fallback, + bool *found_object) { + struct node *n; struct vtable_member vtable_key, *v; int r; @@ -3391,7 +3398,6 @@ int sd_bus_emit_signal( const char *types, ...) { _cleanup_bus_message_unref_ sd_bus_message *m = NULL; - va_list ap; int r; if (!bus) @@ -3405,11 +3411,15 @@ int sd_bus_emit_signal( if (r < 0) return r; - va_start(ap, types); - r = bus_message_append_ap(m, types, ap); - va_end(ap); - if (r < 0) - return r; + if (!isempty(types)) { + va_list ap; + + va_start(ap, types); + r = bus_message_append_ap(m, types, ap); + va_end(ap); + if (r < 0) + return r; + } return sd_bus_send(bus, m, NULL); } @@ -3425,7 +3435,6 @@ int sd_bus_call_method( const char *types, ...) { _cleanup_bus_message_unref_ sd_bus_message *m = NULL; - va_list ap; int r; if (!bus) @@ -3440,11 +3449,15 @@ int sd_bus_call_method( if (r < 0) return r; - va_start(ap, types); - r = bus_message_append_ap(m, types, ap); - va_end(ap); - if (r < 0) - return r; + if (!isempty(types)) { + va_list ap; + + va_start(ap, types); + r = bus_message_append_ap(m, types, ap); + va_end(ap); + if (r < 0) + return r; + } return sd_bus_send_with_reply_and_block(bus, m, 0, error, reply); } @@ -3455,7 +3468,6 @@ int sd_bus_reply_method_return( const char *types, ...) { _cleanup_bus_message_unref_ sd_bus_message *m = NULL; - va_list ap; int r; if (!bus) @@ -3478,11 +3490,15 @@ int sd_bus_reply_method_return( if (r < 0) return r; - va_start(ap, types); - r = bus_message_append_ap(m, types, ap); - va_end(ap); - if (r < 0) - return r; + if (!isempty(types)) { + va_list ap; + + va_start(ap, types); + r = bus_message_append_ap(m, types, ap); + va_end(ap); + if (r < 0) + return r; + } return sd_bus_send(bus, m, NULL); } @@ -3640,7 +3656,7 @@ static int add_object_vtable_internal( sd_bus_object_find_t find, void *userdata) { - struct node_vtable *c, *i; + struct node_vtable *c = NULL, *i; const sd_bus_vtable *v; struct node *n; int r; @@ -3961,7 +3977,7 @@ static int emit_properties_changed_on_interface( struct node_vtable *c; struct node *n; char **property; - void *u; + void *u = NULL; int r; assert(bus); @@ -4034,7 +4050,7 @@ static int emit_properties_changed_on_interface( if (r < 0) return r; - r = v->vtable->property.get(bus, m->path, interface, *property, m, &error, u); + r = v->vtable->property.get(bus, m->path, interface, *property, m, &error, vtable_property_convert_userdata(v->vtable, u)); if (r < 0) return r;