]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
secret: Add NULL obj check to virSecretObjListRemove
authorJohn Ferlan <jferlan@redhat.com>
Tue, 25 Apr 2017 13:17:22 +0000 (09:17 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 26 Apr 2017 17:27:15 +0000 (13:27 -0400)
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

index 169a60bd6a0a6e67c31a36f0b29a903ada58c86a..7c2ad907ac7799d2cead4c2cf5ae13cfeb814001 100644 (file)
@@ -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;
 }