aboutsummaryrefslogtreecommitdiff
path: root/qdev-monitor.c
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2017-11-02 11:10:05 +0100
committerEduardo Habkost <ehabkost@redhat.com>2018-01-19 11:18:51 -0200
commit58346214d03ffcd774e86e3ce72b4196769eb710 (patch)
tree43a25d91cf3cd170e9d603538d65f04a7fb56c93 /qdev-monitor.c
parentef18310d5495c4ce0e1289ed7fc9833d73fe5ee1 (diff)
qdev_monitor: Simplify error handling in qdev_device_add()
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>
Diffstat (limited to 'qdev-monitor.c')
-rw-r--r--qdev-monitor.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/qdev-monitor.c b/qdev-monitor.c
index b4abb4b5ea..2abb80d7e4 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -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;
}