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 92a0df2d75..39ab424873 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7195,8 +7195,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)))
@@ -7206,13 +7206,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:
@@ -7298,9 +7298,6 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
break;
}
- cleanup:
- virObjectUnref(qemuCaps);
- virObjectUnref(domCaps);
return ret;
}
--
2.21.0