summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-internal.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-08-16 22:13:34 +0200
committerLennart Poettering <lennart@poettering.net>2015-08-16 22:13:34 +0200
commit759e02e79dd5e02becff6f34247aac9605ab410e (patch)
treec0ce13b125849bef3f53f5064052c30b35b28090 /src/libsystemd/sd-bus/bus-internal.h
parent0d4605ec3c9c1392bb5f0abc590b1d855df5eebb (diff)
sd-bus: always fill in sd_bus_error paramters, on error
Whenever one of our calls is invoked with a non-NULL, writable sd_bus_error parameter, let's fill in some valid error on failure. We previously only filled in remote errors, but never local errors, which is hard to handle by users. Hence, let's clean this up to always fill in the error. This introduces a new bus_assert_return() macro that works like assert_return() but optionally also initializes a bus_error struct. Fixes #224. Based on a patch by Umut Tezduyar.
Diffstat (limited to 'src/libsystemd/sd-bus/bus-internal.h')
-rw-r--r--src/libsystemd/sd-bus/bus-internal.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libsystemd/sd-bus/bus-internal.h b/src/libsystemd/sd-bus/bus-internal.h
index d420a7594f..9b68fdd642 100644
--- a/src/libsystemd/sd-bus/bus-internal.h
+++ b/src/libsystemd/sd-bus/bus-internal.h
@@ -419,3 +419,9 @@ int bus_maybe_reply_error(sd_bus_message *m, int r, sd_bus_error *error);
bool is_kdbus_wanted(void);
bool is_kdbus_available(void);
+
+#define bus_assert_return(expr, r, error) \
+ do { \
+ if (!assert_log(expr)) \
+ return sd_bus_error_set_errno(error, r); \
+ } while (false)