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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]