Use VIR_AUTO* helpers and get rid of the 'cleanup' label.

Signed-off-by: Peter Krempa <pkre...@redhat.com>
---
 src/qemu/qemu_checkpoint.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c
index 30d1b6ae3a..4430f69911 100644
--- a/src/qemu/qemu_checkpoint.c
+++ b/src/qemu/qemu_checkpoint.c
@@ -363,9 +363,9 @@ qemuCheckpointCreateXML(virDomainPtr domain,
     bool redefine = flags & VIR_DOMAIN_CHECKPOINT_CREATE_REDEFINE;
     unsigned int parse_flags = 0;
     virDomainMomentObjPtr other = NULL;
-    virQEMUDriverConfigPtr cfg = NULL;
-    virCapsPtr caps = NULL;
-    virJSONValuePtr actions = NULL;
+    VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
+    VIR_AUTOUNREF(virCapsPtr) caps = NULL;
+    VIR_AUTOPTR(virJSONValue) actions = NULL;
     int ret;
     VIR_AUTOUNREF(virDomainCheckpointDefPtr) def = NULL;

@@ -380,32 +380,32 @@ qemuCheckpointCreateXML(virDomainPtr domain,
     if (virDomainSnapshotObjListNum(vm->snapshots, NULL, 0) > 0) {
         virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("cannot create checkpoint while snapshot exists"));
-        goto cleanup;
+        return NULL;
     }

     if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BITMAP_MERGE)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("qemu binary lacks persistent bitmaps support"));
-        goto cleanup;
+        return NULL;
     }

     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;
+        return NULL;

     if (!virDomainObjIsActive(vm)) {
         virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("cannot create checkpoint for inactive domain"));
-        goto cleanup;
+        return NULL;
     }

     if (!(def = virDomainCheckpointDefParseString(xmlDesc, caps, 
driver->xmlopt,
                                                   priv->qemuCaps, 
parse_flags)))
-        goto cleanup;
+        return NULL;
     /* Unlike snapshots, the RNG schema already ensured a sane filename. */

     /* We are going to modify the domain below. */
     if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
-        goto cleanup;
+        return NULL;

     if (redefine) {
         if (virDomainCheckpointRedefinePrep(vm, &def, &chk,
@@ -484,10 +484,6 @@ qemuCheckpointCreateXML(virDomainPtr domain,

     qemuDomainObjEndJob(driver, vm);

- cleanup:
-    virJSONValueFree(actions);
-    virObjectUnref(caps);
-    virObjectUnref(cfg);
     return checkpoint;
 }

-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to