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);