mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
virStoragePoolObjAddVol: Simplify error path
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
a5af1a437c
commit
8283450370
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user