summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-objects.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-03-19 21:41:21 +0100
committerLennart Poettering <lennart@poettering.net>2014-03-19 21:41:21 +0100
commita3d59cd1b0a2738d06893948492113f2c35be0af (patch)
treea5a94ef91ca81f73c5a327f37cc0aeabdb491068 /src/libsystemd/sd-bus/bus-objects.c
parent598459cebac7cc93089769a992e7b03287f77e12 (diff)
sd-bus: don't use assert_return() to check for disconnected bus connections
A terminated connection is a runtime error and not a developer mistake, hence don't use assert_return() to check for it.
Diffstat (limited to 'src/libsystemd/sd-bus/bus-objects.c')
-rw-r--r--src/libsystemd/sd-bus/bus-objects.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c
index 08792fea22..539cf2aad1 100644
--- a/src/libsystemd/sd-bus/bus-objects.c
+++ b/src/libsystemd/sd-bus/bus-objects.c
@@ -2199,9 +2199,10 @@ _public_ int sd_bus_emit_properties_changed_strv(
assert_return(bus, -EINVAL);
assert_return(object_path_is_valid(path), -EINVAL);
assert_return(interface_name_is_valid(interface), -EINVAL);
- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
assert_return(!bus_pid_changed(bus), -ECHILD);
+ if (!BUS_IS_OPEN(bus->state))
+ return -ENOTCONN;
/* A non-NULL but empty names list means nothing needs to be
generated. A NULL list OTOH indicates that all properties
@@ -2244,9 +2245,11 @@ _public_ int sd_bus_emit_properties_changed(
assert_return(bus, -EINVAL);
assert_return(object_path_is_valid(path), -EINVAL);
assert_return(interface_name_is_valid(interface), -EINVAL);
- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
assert_return(!bus_pid_changed(bus), -ECHILD);
+ if (!BUS_IS_OPEN(bus->state))
+ return -ENOTCONN;
+
if (!name)
return 0;
@@ -2364,9 +2367,11 @@ _public_ int sd_bus_emit_interfaces_added_strv(sd_bus *bus, const char *path, ch
assert_return(bus, -EINVAL);
assert_return(object_path_is_valid(path), -EINVAL);
- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
assert_return(!bus_pid_changed(bus), -ECHILD);
+ if (!BUS_IS_OPEN(bus->state))
+ return -ENOTCONN;
+
if (strv_isempty(interfaces))
return 0;
@@ -2424,9 +2429,11 @@ _public_ int sd_bus_emit_interfaces_added(sd_bus *bus, const char *path, const c
assert_return(bus, -EINVAL);
assert_return(object_path_is_valid(path), -EINVAL);
- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
assert_return(!bus_pid_changed(bus), -ECHILD);
+ if (!BUS_IS_OPEN(bus->state))
+ return -ENOTCONN;
+
interfaces = strv_from_stdarg_alloca(interface);
return sd_bus_emit_interfaces_added_strv(bus, path, interfaces);
@@ -2438,9 +2445,11 @@ _public_ int sd_bus_emit_interfaces_removed_strv(sd_bus *bus, const char *path,
assert_return(bus, -EINVAL);
assert_return(object_path_is_valid(path), -EINVAL);
- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
assert_return(!bus_pid_changed(bus), -ECHILD);
+ if (!BUS_IS_OPEN(bus->state))
+ return -ENOTCONN;
+
if (strv_isempty(interfaces))
return 0;
@@ -2464,9 +2473,11 @@ _public_ int sd_bus_emit_interfaces_removed(sd_bus *bus, const char *path, const
assert_return(bus, -EINVAL);
assert_return(object_path_is_valid(path), -EINVAL);
- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
assert_return(!bus_pid_changed(bus), -ECHILD);
+ if (!BUS_IS_OPEN(bus->state))
+ return -ENOTCONN;
+
interfaces = strv_from_stdarg_alloca(interface);
return sd_bus_emit_interfaces_removed_strv(bus, path, interfaces);