]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: Cleanup virStorageBackendLogicalFindPoolSourcesFunc
authorJohn Ferlan <jferlan@redhat.com>
Tue, 12 Feb 2019 11:39:50 +0000 (06:39 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 12 Feb 2019 13:51:23 +0000 (08:51 -0500)
Rather than have two error paths, let's use a @retval value and
VIR_STEAL_PTR on @vgname and @pvname to unity the exit path through
the error label.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/storage/storage_backend_logical.c

index fd95bd0d48ed9a13147f529938aab76271291031..46e5bb3ee916129accd5de7c070d0a8756698925 100644 (file)
@@ -484,6 +484,7 @@ virStorageBackendLogicalFindPoolSourcesFunc(char **const groups,
     virStoragePoolSourceListPtr sourceList = data;
     char *pvname = NULL;
     char *vgname = NULL;
+    int retval = -1;
     size_t i;
     virStoragePoolSourceDevicePtr dev;
     virStoragePoolSource *thisSource;
@@ -504,10 +505,8 @@ virStorageBackendLogicalFindPoolSourcesFunc(char **const groups,
         if (!(thisSource = virStoragePoolSourceListNewSource(sourceList)))
             goto error;
 
-        thisSource->name = vgname;
+        VIR_STEAL_PTR(thisSource->name, vgname);
     }
-    else
-        VIR_FREE(vgname);
 
     if (VIR_REALLOC_N(thisSource->devices, thisSource->ndevice + 1) != 0)
         goto error;
@@ -517,15 +516,15 @@ virStorageBackendLogicalFindPoolSourcesFunc(char **const groups,
     thisSource->format = VIR_STORAGE_POOL_LOGICAL_LVM2;
 
     memset(dev, 0, sizeof(*dev));
-    dev->path = pvname;
+    VIR_STEAL_PTR(dev->path, pvname);
 
-    return 0;
+    retval = 0;
 
  error:
     VIR_FREE(pvname);
     VIR_FREE(vgname);
 
-    return -1;
+    return retval;
 }
 
 /*