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(a)redhat.com>
---
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 a1a74b8bd1..e84acf3228 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -4905,27 +4905,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);
@@ -4942,27 +4943,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.6