[libvirt] [PATCH v2 02/11] secret: Add NULL obj check to virSecretObjListRemove

John Ferlan posted 11 patches 8 years, 9 months ago
[libvirt] [PATCH v2 02/11] secret: Add NULL obj check to virSecretObjListRemove
Posted by John Ferlan 8 years, 9 months ago
Rather than have the caller check if !obj before calling, just check
in the function for !obj and return.

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/conf/virsecretobj.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c
index 169a60b..7c2ad90 100644
--- a/src/conf/virsecretobj.c
+++ b/src/conf/virsecretobj.c
@@ -298,6 +298,9 @@ virSecretObjListRemove(virSecretObjListPtr secrets,
 {
     char uuidstr[VIR_UUID_STRING_BUFLEN];
 
+    if (!obj)
+        return;
+
     virUUIDFormat(secret->def->uuid, uuidstr);
     virObjectRef(secret);
     virObjectUnlock(secret);
@@ -915,8 +918,7 @@ virSecretLoad(virSecretObjListPtr secrets,
     secret = NULL;
 
  cleanup:
-    if (secret)
-        virSecretObjListRemove(secrets, secret);
+    virSecretObjListRemove(secrets, secret);
     virSecretDefFree(def);
     return ret;
 }
-- 
2.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list