[libvirt] [PATCH] tests: do not overwrite return value when filling qemuCapsCache

In qemuHotplugCreateObjects, the ret variable was filled by the value returned by qemuTestCapsCacheInsert. If any of the functions after this assignment failed, we would still return success. Also adjust testCompareXMLToArgvHelper, where this change is just cosmetic, because the value was overwritten right away. --- tests/qemuhotplugtest.c | 5 ++--- tests/qemuxml2argvtest.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 1eb2b6a..ea6dc36 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -71,23 +71,22 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, if (!(priv->qemuCaps = virQEMUCapsNew())) goto cleanup; /* for attach & detach qemu must support -device */ virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_VIRTIO_SCSI); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_USB_STORAGE); if (event) virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT); - ret = qemuTestCapsCacheInsert(driver.qemuCapsCache, testname, - priv->qemuCaps); - if (ret < 0) + if (qemuTestCapsCacheInsert(driver.qemuCapsCache, testname, + priv->qemuCaps) < 0) goto cleanup; if (!((*vm)->def = virDomainDefParseString(domxml, driver.caps, driver.xmlopt, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; if (qemuDomainAssignAddresses((*vm)->def, priv->qemuCaps, *vm) < 0) goto cleanup; diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index be74178..39443e2 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -400,23 +400,22 @@ testCompareXMLToArgvHelper(const void *data) virAsprintf(&args, "%s/qemuxml2argvdata/qemuxml2argv-%s.args", abs_srcdir, info->name) < 0) goto cleanup; if (virQEMUCapsGet(info->extraFlags, QEMU_CAPS_MONITOR_JSON)) flags |= FLAG_JSON; if (virQEMUCapsGet(info->extraFlags, QEMU_CAPS_ENABLE_FIPS)) flags |= FLAG_FIPS; - result = qemuTestCapsCacheInsert(driver.qemuCapsCache, info->name, - info->extraFlags); - if (result < 0) + if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->name, + info->extraFlags) < 0) goto cleanup; result = testCompareXMLToArgvFiles(xml, args, info->extraFlags, migrateURI, flags, info->parseFlags); cleanup: VIR_FREE(migrateURI); VIR_FREE(xml); VIR_FREE(args); return result; -- 2.7.3

On Thu, Apr 14, 2016 at 01:58:51PM +0200, Ján Tomko wrote:
In qemuHotplugCreateObjects, the ret variable was filled by the value returned by qemuTestCapsCacheInsert.
If any of the functions after this assignment failed, we would still return success.
Also adjust testCompareXMLToArgvHelper, where this change is just cosmetic, because the value was overwritten right away. --- tests/qemuhotplugtest.c | 5 ++--- tests/qemuxml2argvtest.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-)
ACK Pavel
participants (2)
-
Ján Tomko
-
Pavel Hrdina