Separate storage pool definition assignment into a function. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/conf/virstorageobj.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 7515b5d107..2b9ad6fc98 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -1505,6 +1505,21 @@ virStoragePoolObjSourceFindDuplicate(virStoragePoolObjListPtr pools, } +static void +virStoragePoolObjAssignDef(virStoragePoolObjPtr obj, + virStoragePoolDefPtr def, + unsigned int flgs ATTRIBUTE_UNUSED) +{ + if (!virStoragePoolObjIsActive(obj)) { + virStoragePoolDefFree(obj->def); + obj->def = def; + } else { + virStoragePoolDefFree(obj->newDef); + obj->newDef = def; + } +} + + /** * virStoragePoolObjListAdd: * @pools: Storage Pool object list pointer @@ -1540,14 +1555,8 @@ virStoragePoolObjListAdd(virStoragePoolObjListPtr pools, if (rc < 0) goto error; if (rc > 0) { - if (!virStoragePoolObjIsActive(obj)) { - virStoragePoolDefFree(obj->def); - obj->def = def; - } else { - virStoragePoolDefFree(obj->newDef); - obj->newDef = def; - } virObjectRWUnlock(pools); + virStoragePoolObjAssignDef(obj, def, flags); return obj; } -- 2.21.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list