From 20a61845d3c93c337bf3331a6bac30cf66c2a293 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 9 Aug 2011 11:21:06 +1000 Subject: [PATCH] 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 Reviewed-by: Daniel Stone --- config/dbus.c | 10 +--------- config/hal.c | 10 +--------- config/udev.c | 8 +------- 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);