提交 c69e6ede 编写于 作者: J Jonathon Jongsma 提交者: Cole Robinson

qemu: use g_autoptr in qemuDomainDeviceDefValidate()

This allows us to simplify the function and avoid jumping to 'cleanup'.
Reviewed-by: NCole Robinson <crobinso@redhat.com>
Signed-off-by: NJonathon Jongsma <jjongsma@redhat.com>
上级 ed831437
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册