[libvirt PATCH 02/10] virStoragePoolObjAddVol: Simplify error path

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

 



Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/conf/virstorageobj.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index 99aee9ffb4..1ecf35640c 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -636,14 +636,18 @@ virStoragePoolObjAddVol(virStoragePoolObj *obj,
 
     virObjectRWLockWrite(volumes);
 
-    if (!(volobj = virStorageVolObjNew()))
-        goto error;
-
     if (!voldef->key || !voldef->name || !voldef->target.path ||
         g_hash_table_contains(volumes->objsKey, voldef->key) ||
         g_hash_table_contains(volumes->objsName, voldef->name) ||
-        g_hash_table_contains(volumes->objsPath, voldef->target.path))
-        goto error;
+        g_hash_table_contains(volumes->objsPath, voldef->target.path)) {
+        virObjectRWUnlock(volumes);
+        return -1;
+    }
+
+    if (!(volobj = virStorageVolObjNew())) {
+        virObjectRWUnlock(volumes);
+        return -1;
+    }
 
     g_hash_table_insert(volumes->objsKey, g_strdup(voldef->key), volobj);
     virObjectRef(volobj);
@@ -655,14 +659,10 @@ virStoragePoolObjAddVol(virStoragePoolObj *obj,
     virObjectRef(volobj);
 
     volobj->voldef = voldef;
-    virObjectRWUnlock(volumes);
-    virStorageVolObjEndAPI(&volobj);
-    return 0;
 
- error:
     virStorageVolObjEndAPI(&volobj);
     virObjectRWUnlock(volumes);
-    return -1;
+    return 0;
 }
 
 
-- 
2.31.1




[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