]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: use g_autoptr in qemuDomainDeviceDefValidate()
authorJonathon Jongsma <jjongsma@redhat.com>
Fri, 18 Oct 2019 15:30:10 +0000 (10:30 -0500)
committerCole Robinson <crobinso@redhat.com>
Thu, 14 Nov 2019 16:37:50 +0000 (11:37 -0500)
This allows us to simplify the function and avoid jumping to 'cleanup'.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
src/qemu/qemu_domain.c

index d3b6d61112552b384bcad217881ab0984980a334..d6d10b722cb2b064699e14c3949197f17a7e2456 100644 (file)
@@ -7209,8 +7209,8 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
 {
     int ret = 0;
     virQEMUDriverPtr driver = opaque;
-    virQEMUCapsPtr qemuCaps = NULL;
-    virDomainCapsPtr domCaps = NULL;
+    g_autoptr(virQEMUCaps) qemuCaps = NULL;
+    g_autoptr(virDomainCaps) domCaps = NULL;
 
     if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
                                             def->emulator)))
@@ -7220,13 +7220,13 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
                                                        def->os.machine,
                                                        def->os.arch,
                                                        def->virtType)))
-        goto cleanup;
+        return -1;
 
     if ((ret = qemuDomainDeviceDefValidateAddress(dev, qemuCaps)) < 0)
-        goto cleanup;
+        return ret;
 
     if ((ret = virDomainCapsDeviceDefValidate(domCaps, dev, def)) < 0)
-        goto cleanup;
+        return ret;
 
     switch ((virDomainDeviceType)dev->type) {
     case VIR_DOMAIN_DEVICE_NET:
@@ -7312,9 +7312,6 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
         break;
     }
 
- cleanup:
-    virObjectUnref(qemuCaps);
-    virObjectUnref(domCaps);
     return ret;
 }