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

John Ferlan jferlan at redhat.com
Tue Apr 25 21:15:26 UTC 2017


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 at 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




More information about the libvir-list mailing list