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>
This commit is contained in:
Peter Hutterer 2011-08-09 11:21:06 +10:00
parent d33652dad8
commit 20a61845d3
3 changed files with 3 additions and 25 deletions

View File

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

View File

@ -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;
}

View File

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