A lot of users of virObjectUnlock() use it this way:
if (obj)
virObjectUnlock(obj);
And while passing NULL is not harmless, it generates a warning like
virObjectUnlock:340 : Object 0x0 ((unknown)) is not a virObjectLockable instance
To make this function usage simplier, check if argument is not NULL
before calling virObjectIsClass() and allow caller not to care about
that.
---
src/util/virobject.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/util/virobject.c b/src/util/virobject.c
index 6cb84b4..19e1268 100644
--- a/src/util/virobject.c
+++ b/src/util/virobject.c
@@ -335,6 +335,9 @@ void virObjectUnlock(void *anyobj)
{
virObjectLockablePtr obj = anyobj;
+ if (!obj)
+ return;
+
if (!virObjectIsClass(obj, virObjectLockableClass)) {
VIR_WARN("Object %p (%s) is not a virObjectLockable instance",
obj, obj ? obj->parent.klass->name : "(unknown)");
--
1.9.0