Skip to content

Commit

Permalink
qdev_monitor: Simplify error handling in qdev_device_add()
Browse files Browse the repository at this point in the history
Instead of doing the clean-ups on errors multiple times, introduce
a jump label at the end of the function that can be used by all
error paths that need this cleanup.

Suggested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1509617407-21191-2-git-send-email-thuth@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
  • Loading branch information
huth authored and ehabkost committed Jan 19, 2018
1 parent ef18310 commit 5834621
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions qdev-monitor.c
Expand Up @@ -619,22 +619,22 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)

/* set properties */
if (qemu_opt_foreach(opts, set_property, dev, &err)) {
error_propagate(errp, err);
object_unparent(OBJECT(dev));
object_unref(OBJECT(dev));
return NULL;
goto err_del_dev;
}

dev->opts = opts;
object_property_set_bool(OBJECT(dev), true, "realized", &err);
if (err != NULL) {
error_propagate(errp, err);
dev->opts = NULL;
object_unparent(OBJECT(dev));
object_unref(OBJECT(dev));
return NULL;
goto err_del_dev;
}
return dev;

err_del_dev:
error_propagate(errp, err);
object_unparent(OBJECT(dev));
object_unref(OBJECT(dev));
return NULL;
}


Expand Down

0 comments on commit 5834621

Please sign in to comment.