Instead of explicit virObjectUnlock(obj) + virObjectUnref(obj)
combo the virDomainObjEndAPI() can be used.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/virdomainobjlist.c | 24 +++++++-----------------
src/libxl/libxl_driver.c | 3 +--
2 files changed, 8 insertions(+), 19 deletions(-)
diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c
index 5c40d697dc..ff6c4c1b4f 100644
--- a/src/conf/virdomainobjlist.c
+++ b/src/conf/virdomainobjlist.c
@@ -119,11 +119,8 @@ virDomainObjListFindByID(virDomainObjList *doms,
virObjectRWUnlock(doms);
if (obj) {
virObjectLock(obj);
- if (obj->removing) {
- virObjectUnlock(obj);
- virObjectUnref(obj);
- obj = NULL;
- }
+ if (obj->removing)
+ virDomainObjEndAPI(&obj);
}
return obj;
@@ -165,11 +162,8 @@ virDomainObjListFindByUUID(virDomainObjList *doms,
obj = virDomainObjListFindByUUIDLocked(doms, uuid);
virObjectRWUnlock(doms);
- if (obj && obj->removing) {
- virObjectUnlock(obj);
- virObjectUnref(obj);
- obj = NULL;
- }
+ if (obj && obj->removing)
+ virDomainObjEndAPI(&obj);
return obj;
}
@@ -208,11 +202,8 @@ virDomainObjListFindByName(virDomainObjList *doms,
obj = virDomainObjListFindByNameLocked(doms, name);
virObjectRWUnlock(doms);
- if (obj && obj->removing) {
- virObjectUnlock(obj);
- virObjectUnref(obj);
- obj = NULL;
- }
+ if (obj && obj->removing)
+ virDomainObjEndAPI(&obj);
return obj;
}
@@ -953,8 +944,7 @@ virDomainObjListFilter(virDomainObj ***list,
if (vm->removing ||
(filter && !filter(conn, vm->def)) ||
!virDomainObjMatchFilter(vm, flags)) {
- virObjectUnlock(vm);
- virObjectUnref(vm);
+ virDomainObjEndAPI(&vm);
VIR_DELETE_ELEMENT(*list, i, *nvms);
continue;
}
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 3f67cda9e9..39da10983e 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -461,8 +461,7 @@ libxlReconnectDomain(virDomainObj *vm,
cleanup:
libxl_dominfo_dispose(&d_info);
- virObjectUnlock(vm);
- virObjectUnref(vm);
+ virDomainObjEndAPI(&vm);
virObjectUnref(cfg);
return ret;
--
2.32.0