summaryrefslogtreecommitdiff
path: root/src/shared/dbus-common.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-05-03 23:06:19 +0200
committerLennart Poettering <lennart@poettering.net>2012-05-03 23:06:19 +0200
commit6e476bc9d18c706564d797882df6a27ab2d45b8b (patch)
tree449713aeb86d01bf1c231f03332997ef68fa6c08 /src/shared/dbus-common.h
parent06dab8e18aebf822392c7ca66c5bf3c1200fdec8 (diff)
dbus: handle invalid enum values better
Diffstat (limited to 'src/shared/dbus-common.h')
-rw-r--r--src/shared/dbus-common.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/shared/dbus-common.h b/src/shared/dbus-common.h
index 859812900d..edb8107347 100644
--- a/src/shared/dbus-common.h
+++ b/src/shared/dbus-common.h
@@ -155,7 +155,7 @@ int bus_property_set_uint64(DBusMessageIter *i, const char *property, void *data
assert(i); \
assert(property); \
\
- value = name##_to_string(*field); \
+ value = strempty(name##_to_string(*field)); \
\
if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &value)) \
return -ENOMEM; \
@@ -166,15 +166,18 @@ int bus_property_set_uint64(DBusMessageIter *i, const char *property, void *data
#define DEFINE_BUS_PROPERTY_SET_ENUM(function,name,type) \
int function(DBusMessageIter *i, const char *property, void *data) { \
const char *value; \
- type *field = data; \
+ type f, *field = data; \
\
assert(i); \
assert(property); \
\
dbus_message_iter_get_basic(i, &value); \
\
- *field = name##_from_string(value); \
+ f = name##_from_string(value); \
+ if (f < 0) \
+ return f; \
\
+ *field = f; \
return 0; \
}