This allows us to simplify the function and avoid jumping to 'cleanup'.
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
src/qemu/qemu_domain.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index dc7568fe18..516ae7e444 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7197,8 +7197,8 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
{
int ret = 0;
virQEMUDriverPtr driver = opaque;
- virQEMUCapsPtr qemuCaps = NULL;
- virDomainCapsPtr domCaps = NULL;
+ VIR_AUTOUNREF(virQEMUCapsPtr) qemuCaps = NULL;
+ VIR_AUTOUNREF(virDomainCapsPtr) domCaps = NULL;
if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
def->emulator)))
@@ -7208,13 +7208,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 (virDomainCapsDeviceDefValidate(domCaps, dev, def) < 0)
- goto cleanup;
+ return ret;
switch ((virDomainDeviceType)dev->type) {
case VIR_DOMAIN_DEVICE_NET:
@@ -7300,9 +7300,6 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
break;
}
- cleanup:
- virObjectUnref(qemuCaps);
- virObjectUnref(domCaps);
return ret;
}
--
2.21.0