[PATCH v2 7/9] test: Clean up testStoragePoolCreateXML error processing

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

 



Rather than 2 separate, but same 4 lines of code - let's create an
error label to make a common error path. This will help shortly when
the error path changes slightly.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/test/test_driver.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 568d537e9..0a284e3d1 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -4562,20 +4562,12 @@ testStoragePoolCreateXML(virConnectPtr conn,
          * rename a few fields to mock that. */
         if (testCreateVport(privconn,
                             def->source.adapter.data.fchost.wwnn,
-                            def->source.adapter.data.fchost.wwpn) < 0) {
-            virStoragePoolObjRemove(privconn->pools, obj);
-            virObjectUnref(obj);
-            obj = NULL;
-            goto cleanup;
-        }
+                            def->source.adapter.data.fchost.wwpn) < 0)
+            goto error;
     }
 
-    if (testStoragePoolObjSetDefaults(obj) == -1) {
-        virStoragePoolObjRemove(privconn->pools, obj);
-        virObjectUnref(obj);
-        obj = NULL;
-        goto cleanup;
-    }
+    if (testStoragePoolObjSetDefaults(obj) == -1)
+        goto error;
 
     /* *SetDefaults fills this in for the persistent pools, but this
      * would be a transient pool so remove it; otherwise, the Destroy
@@ -4596,6 +4588,12 @@ testStoragePoolCreateXML(virConnectPtr conn,
     virStoragePoolObjEndAPI(&obj);
     testDriverUnlock(privconn);
     return pool;
+
+ error:
+    virStoragePoolObjRemove(privconn->pools, obj);
+    virObjectUnref(obj);
+    obj = NULL;
+    goto cleanup;
 }
 
 
-- 
2.13.6

--
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]

  Powered by Linux