[PATCH 04/19] test: Create local virStoragePoolObjPtr VolLookup APIs

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

 



Rather than accessing privconn->pools.objs[i] in the for loop,
let's use an @obj variable to make it easier to read the code.

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

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 07eb9d628..7ddff053b 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -4907,27 +4907,28 @@ testStorageVolLookupByKey(virConnectPtr conn,
                           const char *key)
 {
     testDriverPtr privconn = conn->privateData;
+    virStoragePoolObjPtr obj;
     size_t i;
     virStorageVolPtr ret = NULL;
 
     testDriverLock(privconn);
     for (i = 0; i < privconn->pools.count; i++) {
-        virStoragePoolObjLock(privconn->pools.objs[i]);
-        if (virStoragePoolObjIsActive(privconn->pools.objs[i])) {
-            virStorageVolDefPtr privvol =
-                virStorageVolDefFindByKey(privconn->pools.objs[i], key);
+        obj = privconn->pools.objs[i];
+        virStoragePoolObjLock(obj);
+        if (virStoragePoolObjIsActive(obj)) {
+            virStorageVolDefPtr privvol = virStorageVolDefFindByKey(obj, key);
 
             if (privvol) {
                 ret = virGetStorageVol(conn,
-                                       privconn->pools.objs[i]->def->name,
+                                       obj->def->name,
                                        privvol->name,
                                        privvol->key,
                                        NULL, NULL);
-                virStoragePoolObjUnlock(privconn->pools.objs[i]);
+                virStoragePoolObjUnlock(obj);
                 break;
             }
         }
-        virStoragePoolObjUnlock(privconn->pools.objs[i]);
+        virStoragePoolObjUnlock(obj);
     }
     testDriverUnlock(privconn);
 
@@ -4944,27 +4945,28 @@ testStorageVolLookupByPath(virConnectPtr conn,
                            const char *path)
 {
     testDriverPtr privconn = conn->privateData;
+    virStoragePoolObjPtr obj;
     size_t i;
     virStorageVolPtr ret = NULL;
 
     testDriverLock(privconn);
     for (i = 0; i < privconn->pools.count; i++) {
-        virStoragePoolObjLock(privconn->pools.objs[i]);
-        if (virStoragePoolObjIsActive(privconn->pools.objs[i])) {
-            virStorageVolDefPtr privvol =
-                virStorageVolDefFindByPath(privconn->pools.objs[i], path);
+        obj = privconn->pools.objs[i];
+        virStoragePoolObjLock(obj);
+        if (virStoragePoolObjIsActive(obj)) {
+            virStorageVolDefPtr privvol = virStorageVolDefFindByPath(obj, path);
 
             if (privvol) {
                 ret = virGetStorageVol(conn,
-                                       privconn->pools.objs[i]->def->name,
+                                       obj->def->name,
                                        privvol->name,
                                        privvol->key,
                                        NULL, NULL);
-                virStoragePoolObjUnlock(privconn->pools.objs[i]);
+                virStoragePoolObjUnlock(obj);
                 break;
             }
         }
-        virStoragePoolObjUnlock(privconn->pools.objs[i]);
+        virStoragePoolObjUnlock(obj);
     }
     testDriverUnlock(privconn);
 
-- 
2.13.5

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