summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-10-11 20:32:16 +0200
committerLennart Poettering <lennart@poettering.net>2013-10-11 20:32:16 +0200
commit77a874a3fb6f65d2308c20827f005c43bb075752 (patch)
tree077579630bf03b004f2ff998d13f9eab458737aa /src/libsystemd-bus
parent992c052c34d180dd9fe6bd4f89fff3a481a729dc (diff)
bus: don't rely on gccisms/c11 in public header files.
One day sd-bus.h should become a public header file. We generally try to be conservative in language features we use in public headers (much unlike in private code), hence don't make use of anonymous unions in structs for the vtable definitions.
Diffstat (limited to 'src/libsystemd-bus')
-rw-r--r--src/libsystemd-bus/bus-introspect.c14
-rw-r--r--src/libsystemd-bus/bus-objects.c75
2 files changed, 45 insertions, 44 deletions
diff --git a/src/libsystemd-bus/bus-introspect.c b/src/libsystemd-bus/bus-introspect.c
index 8dc9a2de15..c04d9b51f7 100644
--- a/src/libsystemd-bus/bus-introspect.c
+++ b/src/libsystemd-bus/bus-introspect.c
@@ -128,9 +128,9 @@ int introspect_write_interface(struct introspect *i, const char *interface, cons
break;
case _SD_BUS_VTABLE_METHOD:
- fprintf(i->f, " <method name=\"%s\">\n", v->method.member);
- introspect_write_arguments(i, v->method.signature, "in");
- introspect_write_arguments(i, v->method.result, "out");
+ fprintf(i->f, " <method name=\"%s\">\n", v->x.method.member);
+ introspect_write_arguments(i, v->x.method.signature, "in");
+ introspect_write_arguments(i, v->x.method.result, "out");
introspect_write_flags(i, v->type, v->flags);
fputs(" </method>\n", i->f);
break;
@@ -138,16 +138,16 @@ int introspect_write_interface(struct introspect *i, const char *interface, cons
case _SD_BUS_VTABLE_PROPERTY:
case _SD_BUS_VTABLE_WRITABLE_PROPERTY:
fprintf(i->f, " <property name=\"%s\" type=\"%s\" access=\"%s\">\n",
- v->property.member,
- v->property.signature,
+ v->x.property.member,
+ v->x.property.signature,
v->type == _SD_BUS_VTABLE_WRITABLE_PROPERTY ? "readwrite" : "read");
introspect_write_flags(i, v->type, v->flags);
fputs(" </property>\n", i->f);
break;
case _SD_BUS_VTABLE_SIGNAL:
- fprintf(i->f, " <signal name=\"%s\">\n", v->signal.member);
- introspect_write_arguments(i, v->signal.signature, NULL);
+ fprintf(i->f, " <signal name=\"%s\">\n", v->x.signal.member);
+ introspect_write_arguments(i, v->x.signal.signature, NULL);
introspect_write_flags(i, v->type, v->flags);
fputs(" </signal>\n", i->f);
break;
diff --git a/src/libsystemd-bus/bus-objects.c b/src/libsystemd-bus/bus-objects.c
index da49d75031..8d953762be 100644
--- a/src/libsystemd-bus/bus-objects.c
+++ b/src/libsystemd-bus/bus-objects.c
@@ -57,7 +57,7 @@ static int node_vtable_get_userdata(
static void *vtable_property_convert_userdata(const sd_bus_vtable *p, void *u) {
assert(p);
- return (uint8_t*) u + p->property.offset;
+ return (uint8_t*) u + p->x.property.offset;
}
static int vtable_property_get_userdata(
@@ -242,19 +242,19 @@ static int method_callbacks_run(
if (r < 0)
return r;
- if (!streq(strempty(c->vtable->method.signature), signature)) {
+ if (!streq(strempty(c->vtable->x.method.signature), signature)) {
r = sd_bus_reply_method_errorf(bus, m,
"org.freedesktop.DBus.Error.InvalidArgs",
"Invalid arguments '%s' to call %s:%s, expecting '%s'.",
- signature, c->interface, c->member, strempty(c->vtable->method.signature));
+ signature, c->interface, c->member, strempty(c->vtable->x.method.signature));
if (r < 0)
return r;
return 1;
}
- if (c->vtable->method.handler)
- return c->vtable->method.handler(bus, m, u);
+ if (c->vtable->x.method.handler)
+ return c->vtable->x.method.handler(bus, m, u);
/* If the method callback is NULL, make this a successful NOP */
r = sd_bus_reply_method_return(bus, m, NULL);
@@ -280,14 +280,15 @@ static int invoke_property_get(
assert(bus);
assert(v);
- if (v->property.get)
- return v->property.get(bus, path, interface, property, m, error, userdata);
+ if (v->x.property.get)
+ return v->x.property.get(bus, path, interface, property, m, error, userdata);
/* Automatic handling if no callback is defined. */
- assert(bus_type_is_basic(v->property.signature[0]));
+ assert(signature_is_single(v->x.property.signature, false));
+ assert(bus_type_is_basic(v->x.property.signature[0]));
- switch (v->property.signature[0]) {
+ switch (v->x.property.signature[0]) {
case SD_BUS_TYPE_STRING:
case SD_BUS_TYPE_OBJECT_PATH:
@@ -300,7 +301,7 @@ static int invoke_property_get(
break;
}
- r = sd_bus_message_append_basic(m, v->property.signature[0], p);
+ r = sd_bus_message_append_basic(m, v->x.property.signature[0], p);
if (r < 0)
return r;
@@ -322,15 +323,15 @@ static int invoke_property_set(
assert(bus);
assert(v);
- if (v->property.set)
- return v->property.set(bus, path, interface, property, value, error, userdata);
+ if (v->x.property.set)
+ return v->x.property.set(bus, path, interface, property, value, error, userdata);
/* Automatic handling if no callback is defined. */
- assert(signature_is_single(v->property.signature, false));
- assert(bus_type_is_basic(v->property.signature[0]));
+ assert(signature_is_single(v->x.property.signature, false));
+ assert(bus_type_is_basic(v->x.property.signature[0]));
- switch (v->property.signature[0]) {
+ switch (v->x.property.signature[0]) {
case SD_BUS_TYPE_STRING:
case SD_BUS_TYPE_OBJECT_PATH:
@@ -338,7 +339,7 @@ static int invoke_property_set(
const char *p;
char *n;
- r = sd_bus_message_read_basic(value, v->property.signature[0], &p);
+ r = sd_bus_message_read_basic(value, v->x.property.signature[0], &p);
if (r < 0)
return r;
@@ -353,7 +354,7 @@ static int invoke_property_set(
}
default:
- r = sd_bus_message_read_basic(value, v->property.signature[0], userdata);
+ r = sd_bus_message_read_basic(value, v->x.property.signature[0], userdata);
if (r < 0)
return r;
@@ -396,7 +397,7 @@ static int property_get_set_callbacks_run(
c->last_iteration = bus->iteration_counter;
if (is_get) {
- r = sd_bus_message_open_container(reply, 'v', c->vtable->property.signature);
+ r = sd_bus_message_open_container(reply, 'v', c->vtable->x.property.signature);
if (r < 0)
return r;
@@ -420,7 +421,7 @@ static int property_get_set_callbacks_run(
if (c->vtable->type != _SD_BUS_VTABLE_WRITABLE_PROPERTY)
sd_bus_error_setf(&error, "org.freedesktop.DBus.Error.PropertyReadOnly", "Property '%s' is not writable.", c->member);
else {
- r = sd_bus_message_enter_container(m, 'v', c->vtable->property.signature);
+ r = sd_bus_message_enter_container(m, 'v', c->vtable->x.property.signature);
if (r < 0)
return r;
@@ -476,11 +477,11 @@ static int vtable_append_all_properties(
if (r < 0)
return r;
- r = sd_bus_message_open_container(reply, 'v', v->property.signature);
+ r = sd_bus_message_open_container(reply, 'v', v->x.property.signature);
if (r < 0)
return r;
- r = invoke_property_get(bus, v, path, c->interface, v->property.member, reply, error, vtable_property_convert_userdata(v, userdata));
+ r = invoke_property_get(bus, v, path, c->interface, v->x.property.member, reply, error, vtable_property_convert_userdata(v, userdata));
if (r < 0)
return r;
@@ -1321,7 +1322,7 @@ static void free_node_vtable(sd_bus *bus, struct node_vtable *w) {
key.path = w->node->path;
key.interface = w->interface;
- key.member = v->method.member;
+ key.member = v->x.method.member;
x = hashmap_remove(bus->vtable_methods, &key);
break;
@@ -1333,7 +1334,7 @@ static void free_node_vtable(sd_bus *bus, struct node_vtable *w) {
key.path = w->node->path;
key.interface = w->interface;
- key.member = v->property.member;
+ key.member = v->x.property.member;
x = hashmap_remove(bus->vtable_properties, &key);
break;
}}
@@ -1390,7 +1391,7 @@ static int add_object_vtable_internal(
return -EINVAL;
if (!interface_name_is_valid(interface))
return -EINVAL;
- if (!vtable || vtable[0].type != _SD_BUS_VTABLE_START || vtable[0].start.element_size != sizeof(struct sd_bus_vtable))
+ if (!vtable || vtable[0].type != _SD_BUS_VTABLE_START || vtable[0].x.start.element_size != sizeof(struct sd_bus_vtable))
return -EINVAL;
if (bus_pid_changed(bus))
return -ECHILD;
@@ -1444,10 +1445,10 @@ static int add_object_vtable_internal(
case _SD_BUS_VTABLE_METHOD: {
struct vtable_member *m;
- if (!member_name_is_valid(v->method.member) ||
- !signature_is_valid(strempty(v->method.signature), false) ||
- !signature_is_valid(strempty(v->method.result), false) ||
- !(v->method.handler || (isempty(v->method.signature) && isempty(v->method.result))) ||
+ if (!member_name_is_valid(v->x.method.member) ||
+ !signature_is_valid(strempty(v->x.method.signature), false) ||
+ !signature_is_valid(strempty(v->x.method.result), false) ||
+ !(v->x.method.handler || (isempty(v->x.method.signature) && isempty(v->x.method.result))) ||
v->flags & (SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE|SD_BUS_VTABLE_PROPERTY_INVALIDATE_ONLY)) {
r = -EINVAL;
goto fail;
@@ -1462,7 +1463,7 @@ static int add_object_vtable_internal(
m->parent = c;
m->path = n->path;
m->interface = c->interface;
- m->member = v->method.member;
+ m->member = v->x.method.member;
m->vtable = v;
r = hashmap_put(bus->vtable_methods, m, m);
@@ -1476,7 +1477,7 @@ static int add_object_vtable_internal(
case _SD_BUS_VTABLE_WRITABLE_PROPERTY:
- if (!(v->property.set || bus_type_is_basic(v->property.signature[0]))) {
+ if (!(v->x.property.set || bus_type_is_basic(v->x.property.signature[0]))) {
r = -EINVAL;
goto fail;
}
@@ -1486,9 +1487,9 @@ static int add_object_vtable_internal(
case _SD_BUS_VTABLE_PROPERTY: {
struct vtable_member *m;
- if (!member_name_is_valid(v->property.member) ||
- !signature_is_single(v->property.signature, false) ||
- !(v->property.get || bus_type_is_basic(v->property.signature[0])) ||
+ if (!member_name_is_valid(v->x.property.member) ||
+ !signature_is_single(v->x.property.signature, false) ||
+ !(v->x.property.get || bus_type_is_basic(v->x.property.signature[0])) ||
v->flags & SD_BUS_VTABLE_METHOD_NO_REPLY ||
(v->flags & SD_BUS_VTABLE_PROPERTY_INVALIDATE_ONLY && !(v->flags & SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE))) {
r = -EINVAL;
@@ -1505,7 +1506,7 @@ static int add_object_vtable_internal(
m->parent = c;
m->path = n->path;
m->interface = c->interface;
- m->member = v->property.member;
+ m->member = v->x.property.member;
m->vtable = v;
r = hashmap_put(bus->vtable_properties, m, m);
@@ -1519,8 +1520,8 @@ static int add_object_vtable_internal(
case _SD_BUS_VTABLE_SIGNAL:
- if (!member_name_is_valid(v->signal.member) ||
- !signature_is_single(strempty(v->signal.signature), false)) {
+ if (!member_name_is_valid(v->x.signal.member) ||
+ !signature_is_single(strempty(v->x.signal.signature), false)) {
r = -EINVAL;
goto fail;
}
@@ -1776,7 +1777,7 @@ static int emit_properties_changed_on_interface(
if (r < 0)
return r;
- r = sd_bus_message_open_container(m, 'v', v->vtable->property.signature);
+ r = sd_bus_message_open_container(m, 'v', v->vtable->x.property.signature);
if (r < 0)
return r;