summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-08-09 11:21:06 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-08-22 15:56:50 +1000
commit20a61845d3c93c337bf3331a6bac30cf66c2a293 (patch)
tree11df4240e6628f211ab48c9b75d066f7d399968c
parentd33652dad8838ab0a9175ca4613a3161ebc5676f (diff)
config: use add_option for '_source' too
_source was being allocated manually, with all other options added to that list through add_option. Skip the manual part, allocate the first option _source with add_option too. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
-rw-r--r--config/dbus.c10
-rw-r--r--config/hal.c10
-rw-r--r--config/udev.c8
3 files changed, 3 insertions, 25 deletions
diff --git a/config/dbus.c b/config/dbus.c
index 34e3caade..41eca998a 100644
--- a/config/dbus.c
+++ b/config/dbus.c
@@ -80,15 +80,7 @@ add_device(DBusMessage *message, DBusMessage *reply, DBusError *error)
MALFORMED_MESSAGE();
}
- options = calloc(sizeof(*options), 1);
- if (!options) {
- ErrorF("[config/dbus] couldn't allocate option\n");
- return BadAlloc;
- }
-
- options->key = strdup("_source");
- options->value = strdup("client/dbus");
- if (!options->key || !options->value) {
+ if (!add_option(&options, "_source", "client/dbus")) {
ErrorF("[config/dbus] couldn't allocate first key/value pair\n");
ret = BadAlloc;
goto unwind;
diff --git a/config/hal.c b/config/hal.c
index 297520aa6..0b2d7d00c 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -205,15 +205,7 @@ device_added(LibHalContext *hal_ctx, const char *udi)
free(parent);
}
- options = calloc(sizeof(*options), 1);
- if (!options){
- LogMessage(X_ERROR, "config/hal: couldn't allocate space for input options!\n");
- goto unwind;
- }
-
- options->key = strdup("_source");
- options->value = strdup("server/hal");
- if (!options->key || !options->value) {
+ if (!add_option(&options, "_source", "server/hal")) {
LogMessage(X_ERROR, "config/hal: couldn't allocate first key/value pair\n");
goto unwind;
}
diff --git a/config/udev.c b/config/udev.c
index b11c81d8e..1f431c1d3 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -93,13 +93,7 @@ device_added(struct udev_device *udev_device)
return;
}
- options = calloc(sizeof(*options), 1);
- if (!options)
- return;
-
- options->key = strdup("_source");
- options->value = strdup("server/udev");
- if (!options->key || !options->value)
+ if (!add_option(&options, "_source", "server/udev"))
goto unwind;
parent = udev_device_get_parent(udev_device);