qemu: use g_autoptr in qemuDomainDeviceDefValidate()

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>
This commit is contained in:
Jonathon Jongsma 2019-10-18 10:30:10 -05:00 committed by Cole Robinson
parent ed831437af
commit c69e6edea3

View File

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