]> xenbits.xensource.com Git - libvirt.git/commitdiff
secret: Remove need for local configFile and base64File in ObjectAdd
authorJohn Ferlan <jferlan@redhat.com>
Wed, 31 May 2017 19:11:28 +0000 (15:11 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 25 Jul 2017 13:11:48 +0000 (09:11 -0400)
Rather than assign to a local variable, let's just assign directly to the
object using the error path for cleanup.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/conf/virsecretobj.c

index 792ceb1f15146edcec828c5394b46df49f143338..850fdaf8b256ec090b1dd5058dbb9d1559a2f2ee 100644 (file)
@@ -335,7 +335,6 @@ virSecretObjListAdd(virSecretObjListPtr secrets,
     virSecretDefPtr objdef;
     virSecretObjPtr ret = NULL;
     char uuidstr[VIR_UUID_STRING_BUFLEN];
-    char *configFile = NULL, *base64File = NULL;
 
     virObjectLock(secrets);
 
@@ -384,22 +383,20 @@ virSecretObjListAdd(virSecretObjListPtr secrets,
             goto cleanup;
         }
 
+        if (!(obj = virSecretObjNew()))
+            goto cleanup;
+
         /* Generate the possible configFile and base64File strings
          * using the configDir, uuidstr, and appropriate suffix
          */
-        if (!(configFile = virFileBuildPath(configDir, uuidstr, ".xml")) ||
-            !(base64File = virFileBuildPath(configDir, uuidstr, ".base64")))
-            goto cleanup;
-
-        if (!(obj = virSecretObjNew()))
+        if (!(obj->configFile = virFileBuildPath(configDir, uuidstr, ".xml")) ||
+            !(obj->base64File = virFileBuildPath(configDir, uuidstr, ".base64")))
             goto cleanup;
 
         if (virHashAddEntry(secrets->objs, uuidstr, obj) < 0)
             goto cleanup;
 
         obj->def = newdef;
-        VIR_STEAL_PTR(obj->configFile, configFile);
-        VIR_STEAL_PTR(obj->base64File, base64File);
         virObjectRef(obj);
     }
 
@@ -408,8 +405,6 @@ virSecretObjListAdd(virSecretObjListPtr secrets,
 
  cleanup:
     virSecretObjEndAPI(&obj);
-    VIR_FREE(configFile);
-    VIR_FREE(base64File);
     virObjectUnlock(secrets);
     return ret;
 }