mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
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:
parent
ed831437af
commit
c69e6edea3
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user