提交 30d99eb5 编写于 作者: P Peter Krempa

storage: Clean up unlocking of storage pool objects

Most of the APIs now don't reach the cleanup section when the pool
object wasn't found and thus don't need to check before unlocking it.
上级 efd89276
...@@ -289,8 +289,7 @@ storagePoolLookupByUUID(virConnectPtr conn, ...@@ -289,8 +289,7 @@ storagePoolLookupByUUID(virConnectPtr conn,
NULL, NULL); NULL, NULL);
cleanup: cleanup:
if (pool) virStoragePoolObjUnlock(pool);
virStoragePoolObjUnlock(pool);
return ret; return ret;
} }
...@@ -309,7 +308,7 @@ storagePoolLookupByName(virConnectPtr conn, ...@@ -309,7 +308,7 @@ storagePoolLookupByName(virConnectPtr conn,
if (!pool) { if (!pool) {
virReportError(VIR_ERR_NO_STORAGE_POOL, virReportError(VIR_ERR_NO_STORAGE_POOL,
_("no storage pool with matching name '%s'"), name); _("no storage pool with matching name '%s'"), name);
goto cleanup; return NULL;
} }
if (virStoragePoolLookupByNameEnsureACL(conn, pool->def) < 0) if (virStoragePoolLookupByNameEnsureACL(conn, pool->def) < 0)
...@@ -319,8 +318,7 @@ storagePoolLookupByName(virConnectPtr conn, ...@@ -319,8 +318,7 @@ storagePoolLookupByName(virConnectPtr conn,
NULL, NULL); NULL, NULL);
cleanup: cleanup:
if (pool) virStoragePoolObjUnlock(pool);
virStoragePoolObjUnlock(pool);
return ret; return ret;
} }
...@@ -338,7 +336,7 @@ storagePoolLookupByVolume(virStorageVolPtr vol) ...@@ -338,7 +336,7 @@ storagePoolLookupByVolume(virStorageVolPtr vol)
if (!pool) { if (!pool) {
virReportError(VIR_ERR_NO_STORAGE_POOL, virReportError(VIR_ERR_NO_STORAGE_POOL,
_("no storage pool with matching name '%s'"), vol->pool); _("no storage pool with matching name '%s'"), vol->pool);
goto cleanup; return NULL;
} }
if (virStoragePoolLookupByVolumeEnsureACL(vol->conn, pool->def) < 0) if (virStoragePoolLookupByVolumeEnsureACL(vol->conn, pool->def) < 0)
...@@ -348,8 +346,7 @@ storagePoolLookupByVolume(virStorageVolPtr vol) ...@@ -348,8 +346,7 @@ storagePoolLookupByVolume(virStorageVolPtr vol)
NULL, NULL); NULL, NULL);
cleanup: cleanup:
if (pool) virStoragePoolObjUnlock(pool);
virStoragePoolObjUnlock(pool);
return ret; return ret;
} }
...@@ -571,8 +568,7 @@ static int storagePoolIsActive(virStoragePoolPtr pool) ...@@ -571,8 +568,7 @@ static int storagePoolIsActive(virStoragePoolPtr pool)
ret = virStoragePoolObjIsActive(obj); ret = virStoragePoolObjIsActive(obj);
cleanup: cleanup:
if (obj) virStoragePoolObjUnlock(obj);
virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -590,8 +586,7 @@ static int storagePoolIsPersistent(virStoragePoolPtr pool) ...@@ -590,8 +586,7 @@ static int storagePoolIsPersistent(virStoragePoolPtr pool)
ret = obj->configFile ? 1 : 0; ret = obj->configFile ? 1 : 0;
cleanup: cleanup:
if (obj) virStoragePoolObjUnlock(obj);
virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -805,8 +800,7 @@ storagePoolCreate(virStoragePoolPtr obj, ...@@ -805,8 +800,7 @@ storagePoolCreate(virStoragePoolPtr obj,
ret = 0; ret = 0;
cleanup: cleanup:
if (pool) virStoragePoolObjUnlock(pool);
virStoragePoolObjUnlock(pool);
return ret; return ret;
} }
...@@ -840,8 +834,7 @@ storagePoolBuild(virStoragePoolPtr obj, ...@@ -840,8 +834,7 @@ storagePoolBuild(virStoragePoolPtr obj,
ret = 0; ret = 0;
cleanup: cleanup:
if (pool) virStoragePoolObjUnlock(pool);
virStoragePoolObjUnlock(pool);
return ret; return ret;
} }
...@@ -951,8 +944,7 @@ storagePoolDelete(virStoragePoolPtr obj, ...@@ -951,8 +944,7 @@ storagePoolDelete(virStoragePoolPtr obj,
ret = 0; ret = 0;
cleanup: cleanup:
if (pool) virStoragePoolObjUnlock(pool);
virStoragePoolObjUnlock(pool);
return ret; return ret;
} }
...@@ -1047,8 +1039,7 @@ storagePoolGetInfo(virStoragePoolPtr obj, ...@@ -1047,8 +1039,7 @@ storagePoolGetInfo(virStoragePoolPtr obj,
ret = 0; ret = 0;
cleanup: cleanup:
if (pool) virStoragePoolObjUnlock(pool);
virStoragePoolObjUnlock(pool);
return ret; return ret;
} }
...@@ -1076,8 +1067,7 @@ storagePoolGetXMLDesc(virStoragePoolPtr obj, ...@@ -1076,8 +1067,7 @@ storagePoolGetXMLDesc(virStoragePoolPtr obj,
ret = virStoragePoolDefFormat(def); ret = virStoragePoolDefFormat(def);
cleanup: cleanup:
if (pool) virStoragePoolObjUnlock(pool);
virStoragePoolObjUnlock(pool);
return ret; return ret;
} }
...@@ -1102,8 +1092,7 @@ storagePoolGetAutostart(virStoragePoolPtr obj, ...@@ -1102,8 +1092,7 @@ storagePoolGetAutostart(virStoragePoolPtr obj,
ret = 0; ret = 0;
cleanup: cleanup:
if (pool) virStoragePoolObjUnlock(pool);
virStoragePoolObjUnlock(pool);
return ret; return ret;
} }
...@@ -1200,8 +1189,7 @@ storagePoolNumOfVolumes(virStoragePoolPtr obj) ...@@ -1200,8 +1189,7 @@ storagePoolNumOfVolumes(virStoragePoolPtr obj)
} }
cleanup: cleanup:
if (pool) virStoragePoolObjUnlock(pool);
virStoragePoolObjUnlock(pool);
return ret; return ret;
} }
...@@ -1240,8 +1228,7 @@ storagePoolListVolumes(virStoragePoolPtr obj, ...@@ -1240,8 +1228,7 @@ storagePoolListVolumes(virStoragePoolPtr obj,
return n; return n;
cleanup: cleanup:
if (pool) virStoragePoolObjUnlock(pool);
virStoragePoolObjUnlock(pool);
for (n = 0; n < maxnames; n++) for (n = 0; n < maxnames; n++)
VIR_FREE(names[n]); VIR_FREE(names[n]);
...@@ -1309,8 +1296,7 @@ storagePoolListAllVolumes(virStoragePoolPtr pool, ...@@ -1309,8 +1296,7 @@ storagePoolListAllVolumes(virStoragePoolPtr pool,
VIR_FREE(tmp_vols); VIR_FREE(tmp_vols);
} }
if (obj) virStoragePoolObjUnlock(obj);
virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -1348,8 +1334,7 @@ storageVolLookupByName(virStoragePoolPtr obj, ...@@ -1348,8 +1334,7 @@ storageVolLookupByName(virStoragePoolPtr obj,
NULL, NULL); NULL, NULL);
cleanup: cleanup:
if (pool) virStoragePoolObjUnlock(pool);
virStoragePoolObjUnlock(pool);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册