[PATCH v2 07/32] conf: Introduce VIR_DEFINE_AUTOPTR_FUNC for virStorageVolDef

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
Reviewed-by: Erik Skultety <eskultet@xxxxxxxxxx>
---
 src/conf/storage_conf.c                    |  3 +--
 src/conf/storage_conf.h                    |  1 +
 src/esx/esx_storage_backend_vmfs.c         |  6 ++----
 src/phyp/phyp_driver.c                     |  3 +--
 src/storage/storage_backend_gluster.c      |  3 +--
 src/storage/storage_backend_iscsi_direct.c | 19 +++++++----------
 src/storage/storage_backend_mpath.c        | 24 ++++++++--------------
 src/storage/storage_backend_rbd.c          |  9 +++-----
 src/storage/storage_backend_sheepdog.c     | 15 ++++++--------
 src/storage/storage_driver.c               |  6 ++----
 src/storage/storage_util.c                 |  6 ++----
 src/test/test_driver.c                     | 10 ++++-----
 src/vbox/vbox_storage.c                    |  3 +--
 tests/storagebackendsheepdogtest.c         |  3 +--
 tests/storagevolxml2argvtest.c             |  5 ++---
 tests/storagevolxml2xmltest.c              |  3 +--
 16 files changed, 44 insertions(+), 75 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 0ebdbafa0c..e6accb14c6 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1168,7 +1168,6 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
                          xmlXPathContextPtr ctxt,
                          unsigned int flags)
 {
-    virStorageVolDefPtr def;
     virStorageVolDefPtr ret = NULL;
     virStorageVolOptionsPtr options;
     char *type = NULL;
@@ -1180,6 +1179,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
     xmlNodePtr *nodes = NULL;
     size_t i;
     int n;
+    VIR_AUTOPTR(virStorageVolDef) def = NULL;
 
     virCheckFlags(VIR_VOL_XML_PARSE_NO_CAPACITY |
                   VIR_VOL_XML_PARSE_OPT_CAPACITY, NULL);
@@ -1331,7 +1331,6 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
     VIR_STEAL_PTR(ret, def);
 
  cleanup:
-    virStorageVolDefFree(def);
     VIR_FREE(nodes);
     VIR_FREE(allocation);
     VIR_FREE(capacity);
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 3fa97bba76..b8e73864c4 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -461,5 +461,6 @@ VIR_ENUM_DECL(virStoragePartedFs);
                  VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE)
 
 VIR_DEFINE_AUTOPTR_FUNC(virStoragePoolSource, virStoragePoolSourceFree);
+VIR_DEFINE_AUTOPTR_FUNC(virStorageVolDef, virStorageVolDefFree);
 
 #endif /* LIBVIRT_STORAGE_CONF_H */
diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c
index 8458d4e95c..6d6bd1a6ce 100644
--- a/src/esx/esx_storage_backend_vmfs.c
+++ b/src/esx/esx_storage_backend_vmfs.c
@@ -836,7 +836,6 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
     virStorageVolPtr volume = NULL;
     esxPrivate *priv = pool->conn->privateData;
     virStoragePoolDef poolDef;
-    virStorageVolDefPtr def = NULL;
     char *tmp;
     char *unescapedDatastorePath = NULL;
     char *unescapedDirectoryName = NULL;
@@ -852,6 +851,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
     char *taskInfoErrorMessage = NULL;
     char *uuid_string = NULL;
     char *key = NULL;
+    VIR_AUTOPTR(virStorageVolDef) def = NULL;
 
     virCheckFlags(0, NULL);
 
@@ -1024,7 +1024,6 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
         virtualDiskSpec->adapterType = NULL;
     }
 
-    virStorageVolDefFree(def);
     VIR_FREE(unescapedDatastorePath);
     VIR_FREE(unescapedDirectoryName);
     VIR_FREE(unescapedDirectoryAndFileName);
@@ -1054,7 +1053,6 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
     esxPrivate *priv = pool->conn->privateData;
     virStoragePoolDef poolDef;
     char *sourceDatastorePath = NULL;
-    virStorageVolDefPtr def = NULL;
     char *tmp;
     char *unescapedDatastorePath = NULL;
     char *unescapedDirectoryName = NULL;
@@ -1069,6 +1067,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
     char *taskInfoErrorMessage = NULL;
     char *uuid_string = NULL;
     char *key = NULL;
+    VIR_AUTOPTR(virStorageVolDef) def = NULL;
 
     virCheckFlags(0, NULL);
 
@@ -1207,7 +1206,6 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
 
  cleanup:
     VIR_FREE(sourceDatastorePath);
-    virStorageVolDefFree(def);
     VIR_FREE(unescapedDatastorePath);
     VIR_FREE(unescapedDirectoryName);
     VIR_FREE(unescapedDirectoryAndFileName);
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 4ffa08ff43..cac5642afd 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1952,11 +1952,11 @@ phypStorageVolCreateXML(virStoragePoolPtr pool,
 {
     virCheckFlags(0, NULL);
 
-    virStorageVolDefPtr voldef = NULL;
     virStoragePoolDefPtr spdef = NULL;
     virStorageVolPtr vol = NULL;
     virStorageVolPtr dup_vol = NULL;
     char *key = NULL;
+    VIR_AUTOPTR(virStorageVolDef) voldef = NULL;
 
     if (VIR_ALLOC(spdef) < 0)
         return NULL;
@@ -2036,7 +2036,6 @@ phypStorageVolCreateXML(virStoragePoolPtr pool,
 
  err:
     VIR_FREE(key);
-    virStorageVolDefFree(voldef);
     virStoragePoolDefFree(spdef);
     virObjectUnref(vol);
     return NULL;
diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
index 6759d7f1e5..5428bb92ba 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -242,12 +242,12 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
                                    virStorageVolDefPtr *volptr)
 {
     int ret = -1;
-    virStorageVolDefPtr vol = NULL;
     glfs_fd_t *fd = NULL;
     virStorageSourcePtr meta = NULL;
     char *header = NULL;
     ssize_t len;
     int backingFormat;
+    VIR_AUTOPTR(virStorageVolDef) vol = NULL;
 
     *volptr = NULL;
 
@@ -331,7 +331,6 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
     ret = 0;
  cleanup:
     virStorageSourceFree(meta);
-    virStorageVolDefFree(vol);
     if (fd)
         glfs_close(fd);
     VIR_FREE(header);
diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/storage_backend_iscsi_direct.c
index 8d12c1a274..42060dd758 100644
--- a/src/storage/storage_backend_iscsi_direct.c
+++ b/src/storage/storage_backend_iscsi_direct.c
@@ -305,22 +305,21 @@ virISCSIDirectRefreshVol(virStoragePoolObjPtr pool,
                          char *portal)
 {
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
-    virStorageVolDefPtr vol = NULL;
     uint32_t block_size;
     uint32_t nb_block;
-    int ret = -1;
+    VIR_AUTOPTR(virStorageVolDef) vol = NULL;
 
     virStoragePoolObjClearVols(pool);
     if (virISCSIDirectTestUnitReady(iscsi, lun) < 0)
-        goto cleanup;
+        return -1;
 
     if (VIR_ALLOC(vol) < 0)
-        goto cleanup;
+        return -1;
 
     vol->type = VIR_STORAGE_VOL_NETWORK;
 
     if (virISCSIDirectGetVolumeCapacity(iscsi, lun, &block_size, &nb_block) < 0)
-        goto cleanup;
+        return -1;
 
     vol->target.capacity = block_size * nb_block;
     vol->target.allocation = block_size * nb_block;
@@ -328,17 +327,13 @@ virISCSIDirectRefreshVol(virStoragePoolObjPtr pool,
     def->allocation += vol->target.allocation;
 
     if (virISCSIDirectSetVolumeAttributes(pool, vol, lun, portal) < 0)
-        goto cleanup;
+        return -1;
 
     if (virStoragePoolObjAddVol(pool, vol) < 0)
-        goto cleanup;
-
+        return -1;
     vol = NULL;
 
-    ret = 0;
- cleanup:
-    virStorageVolDefFree(vol);
-    return ret;
+    return 0;
 }
 
 static int
diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c
index b3a49ee1b2..423f945fbc 100644
--- a/src/storage/storage_backend_mpath.c
+++ b/src/storage/storage_backend_mpath.c
@@ -46,42 +46,36 @@ virStorageBackendMpathNewVol(virStoragePoolObjPtr pool,
                              const char *dev)
 {
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
-    virStorageVolDefPtr vol;
-    int ret = -1;
+    VIR_AUTOPTR(virStorageVolDef) vol = NULL;
 
     if (VIR_ALLOC(vol) < 0)
-        goto cleanup;
+        return -1;
 
     vol->type = VIR_STORAGE_VOL_BLOCK;
 
     if (virAsprintf(&(vol->name), "dm-%u", devnum) < 0)
-        goto cleanup;
+        return -1;
 
     if (virAsprintf(&vol->target.path, "/dev/%s", dev) < 0)
-        goto cleanup;
+        return -1;
 
     if (virStorageBackendUpdateVolInfo(vol, true,
                                        VIR_STORAGE_VOL_OPEN_DEFAULT, 0) < 0) {
-        goto cleanup;
+        return -1;
     }
 
     /* XXX should use logical unit's UUID instead */
     if (VIR_STRDUP(vol->key, vol->target.path) < 0)
-        goto cleanup;
+        return -1;
 
     if (virStoragePoolObjAddVol(pool, vol) < 0)
-        goto cleanup;
+        return -1;
 
     def->capacity += vol->target.capacity;
     def->allocation += vol->target.allocation;
-    ret = 0;
-
- cleanup:
+    vol = NULL;
 
-    if (ret != 0)
-        virStorageVolDefFree(vol);
-
-    return ret;
+    return 0;
 }
 
 
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index cfbce1ad19..ece04f0f2d 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -618,7 +618,7 @@ virStorageBackendRBDRefreshPool(virStoragePoolObjPtr pool)
     }
 
     for (name = names; name < names + max_size;) {
-        virStorageVolDefPtr vol;
+        VIR_AUTOPTR(virStorageVolDef) vol = NULL;
 
         if (STREQ(name, ""))
             break;
@@ -626,10 +626,8 @@ virStorageBackendRBDRefreshPool(virStoragePoolObjPtr pool)
         if (VIR_ALLOC(vol) < 0)
             goto cleanup;
 
-        if (VIR_STRDUP(vol->name, name) < 0) {
-            VIR_FREE(vol);
+        if (VIR_STRDUP(vol->name, name) < 0)
             goto cleanup;
-        }
 
         name += strlen(name) + 1;
 
@@ -648,15 +646,14 @@ virStorageBackendRBDRefreshPool(virStoragePoolObjPtr pool)
             if (r == -ENOENT || r == -ETIMEDOUT)
                 continue;
 
-            virStorageVolDefFree(vol);
             goto cleanup;
         }
 
         if (virStoragePoolObjAddVol(pool, vol) < 0) {
-            virStorageVolDefFree(vol);
             virStoragePoolObjClearVols(pool);
             goto cleanup;
         }
+        vol = NULL;
     }
 
     VIR_DEBUG("Found %zu images in RBD pool %s",
diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
index b6f424bea1..7cba6e02aa 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -110,30 +110,27 @@ virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
 static int
 virStorageBackendSheepdogAddVolume(virStoragePoolObjPtr pool, const char *diskInfo)
 {
-    virStorageVolDefPtr vol = NULL;
+    VIR_AUTOPTR(virStorageVolDef) vol = NULL;
 
     if (diskInfo == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Missing disk info when adding volume"));
-        goto error;
+        return -1;
     }
 
     if (VIR_ALLOC(vol) < 0 || VIR_STRDUP(vol->name, diskInfo) < 0)
-        goto error;
+        return -1;
 
     vol->type = VIR_STORAGE_VOL_NETWORK;
 
     if (virStorageBackendSheepdogRefreshVol(pool, vol) < 0)
-        goto error;
+        return -1;
 
     if (virStoragePoolObjAddVol(pool, vol) < 0)
-        goto error;
+        return -1;
+    vol = NULL;
 
     return 0;
-
- error:
-    virStorageVolDefFree(vol);
-    return -1;
 }
 
 static int
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 878a40cac5..c50a8ef5d4 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1820,8 +1820,8 @@ storageVolCreateXML(virStoragePoolPtr pool,
     virStoragePoolObjPtr obj;
     virStoragePoolDefPtr def;
     virStorageBackendPtr backend;
-    virStorageVolDefPtr voldef = NULL;
     virStorageVolPtr vol = NULL, newvol = NULL;
+    VIR_AUTOPTR(virStorageVolDef) voldef = NULL;
 
     virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL);
 
@@ -1941,7 +1941,6 @@ storageVolCreateXML(virStoragePoolPtr pool,
 
  cleanup:
     virObjectUnref(newvol);
-    virStorageVolDefFree(voldef);
     virStoragePoolObjEndAPI(&obj);
     return vol;
 }
@@ -1957,11 +1956,11 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
     virStoragePoolObjPtr objsrc = NULL;
     virStorageBackendPtr backend;
     virStorageVolDefPtr voldefsrc = NULL;
-    virStorageVolDefPtr voldef = NULL;
     virStorageVolDefPtr shadowvol = NULL;
     virStorageVolPtr newvol = NULL;
     virStorageVolPtr vol = NULL;
     int buildret;
+    VIR_AUTOPTR(virStorageVolDef) voldef = NULL;
 
     virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA |
                   VIR_STORAGE_VOL_CREATE_REFLINK,
@@ -2134,7 +2133,6 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
 
  cleanup:
     virObjectUnref(newvol);
-    virStorageVolDefFree(voldef);
     VIR_FREE(shadowvol);
     virStoragePoolObjEndAPI(&obj);
     virStoragePoolObjEndAPI(&objsrc);
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 95e05d950b..1770d21f33 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -3672,10 +3672,10 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
     struct dirent *ent;
     struct statvfs sb;
     struct stat statbuf;
-    virStorageVolDefPtr vol = NULL;
     virStorageSourcePtr target = NULL;
     int direrr;
     int fd = -1, ret = -1;
+    VIR_AUTOPTR(virStorageVolDef) vol = NULL;
 
     if (virDirOpen(&dir, def->target.path) < 0)
         goto cleanup;
@@ -3767,7 +3767,6 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
  cleanup:
     VIR_DIR_CLOSE(dir);
     VIR_FORCE_CLOSE(fd);
-    virStorageVolDefFree(vol);
     virStorageSourceFree(target);
     if (ret < 0)
         virStoragePoolObjClearVols(pool);
@@ -3816,9 +3815,9 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
                             const char *dev)
 {
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
-    virStorageVolDefPtr vol = NULL;
     char *devpath = NULL;
     int retval = -1;
+    VIR_AUTOPTR(virStorageVolDef) vol = NULL;
 
     /* Check if the pool is using a stable target path. The call to
      * virStorageBackendStablePath will fail if the pool target path
@@ -3898,7 +3897,6 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
     retval = 0;
 
  cleanup:
-    virStorageVolDefFree(vol);
     VIR_FREE(devpath);
     return retval;
 }
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index de221b4190..f07a075755 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1025,7 +1025,7 @@ testOpenVolumesForPool(const char *file,
     size_t i;
     int num, ret = -1;
     xmlNodePtr *nodes = NULL;
-    virStorageVolDefPtr volDef = NULL;
+    VIR_AUTOPTR(virStorageVolDef) volDef = NULL;
 
     /* Find storage volumes */
     if (virAsprintf(&vol_xpath, "/node/pool[%d]/volume", objidx) < 0)
@@ -1064,7 +1064,6 @@ testOpenVolumesForPool(const char *file,
 
     ret = 0;
  error:
-    virStorageVolDefFree(volDef);
     VIR_FREE(nodes);
     return ret;
 }
@@ -5053,8 +5052,8 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
     testDriverPtr privconn = pool->conn->privateData;
     virStoragePoolObjPtr obj;
     virStoragePoolDefPtr def;
-    virStorageVolDefPtr privvol = NULL;
     virStorageVolPtr ret = NULL;
+    VIR_AUTOPTR(virStorageVolDef) privvol = NULL;
 
     virCheckFlags(0, NULL);
 
@@ -5098,7 +5097,6 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
     privvol = NULL;
 
  cleanup:
-    virStorageVolDefFree(privvol);
     virStoragePoolObjEndAPI(&obj);
     return ret;
 }
@@ -5113,8 +5111,9 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
     testDriverPtr privconn = pool->conn->privateData;
     virStoragePoolObjPtr obj;
     virStoragePoolDefPtr def;
-    virStorageVolDefPtr privvol = NULL, origvol = NULL;
+    virStorageVolDefPtr origvol = NULL;
     virStorageVolPtr ret = NULL;
+    VIR_AUTOPTR(virStorageVolDef) privvol = NULL;
 
     virCheckFlags(0, NULL);
 
@@ -5166,7 +5165,6 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
     privvol = NULL;
 
  cleanup:
-    virStorageVolDefFree(privvol);
     virStoragePoolObjEndAPI(&obj);
     return ret;
 }
diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c
index 7047e54084..ae16094dbe 100644
--- a/src/vbox/vbox_storage.c
+++ b/src/vbox/vbox_storage.c
@@ -401,7 +401,6 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
                         const char *xml, unsigned int flags)
 {
     vboxDriverPtr data = pool->conn->privateData;
-    virStorageVolDefPtr def = NULL;
     PRUnichar *hddFormatUtf16 = NULL;
     PRUnichar *hddNameUtf16 = NULL;
     virStoragePoolDef poolDef;
@@ -415,6 +414,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
     PRUint32 variant = HardDiskVariant_Standard;
     resultCodeUnion resultCode;
     virStorageVolPtr ret = NULL;
+    VIR_AUTOPTR(virStorageVolDef) def = NULL;
 
     if (!data->vboxObj)
         return ret;
@@ -501,7 +501,6 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
     VBOX_RELEASE(progress);
     VBOX_UTF16_FREE(hddFormatUtf16);
     VBOX_UTF16_FREE(hddNameUtf16);
-    virStorageVolDefFree(def);
     return ret;
 }
 
diff --git a/tests/storagebackendsheepdogtest.c b/tests/storagebackendsheepdogtest.c
index 616af22d73..540f89c3ab 100644
--- a/tests/storagebackendsheepdogtest.c
+++ b/tests/storagebackendsheepdogtest.c
@@ -94,7 +94,7 @@ test_vdi_list_parser(const void *opaque)
     int ret = -1;
     char *output = NULL;
     virStoragePoolDefPtr pool = NULL;
-    virStorageVolDefPtr vol = NULL;
+    VIR_AUTOPTR(virStorageVolDef) vol = NULL;
 
     if (!(pool = virStoragePoolDefParseFile(data->poolxml)))
         goto cleanup;
@@ -121,7 +121,6 @@ test_vdi_list_parser(const void *opaque)
  cleanup:
     VIR_FREE(output);
     virStoragePoolDefFree(pool);
-    virStorageVolDefFree(vol);
     return ret;
 }
 
diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c
index bc2da37410..4c98decc4d 100644
--- a/tests/storagevolxml2argvtest.c
+++ b/tests/storagevolxml2argvtest.c
@@ -48,10 +48,11 @@ testCompareXMLToArgvFiles(bool shouldFail,
 
     virCommandPtr cmd = NULL;
 
-    virStorageVolDefPtr vol = NULL, inputvol = NULL;
     virStoragePoolDefPtr def = NULL;
     virStoragePoolDefPtr inputpool = NULL;
     virStoragePoolObjPtr obj = NULL;
+    VIR_AUTOPTR(virStorageVolDef) vol = NULL;
+    VIR_AUTOPTR(virStorageVolDef) inputvol = NULL;
 
     if (!(def = virStoragePoolDefParseFile(poolxml)))
         goto cleanup;
@@ -139,8 +140,6 @@ testCompareXMLToArgvFiles(bool shouldFail,
 
  cleanup:
     virStoragePoolDefFree(inputpool);
-    virStorageVolDefFree(vol);
-    virStorageVolDefFree(inputvol);
     virCommandFree(cmd);
     VIR_FREE(actualCmdline);
     virStoragePoolObjEndAPI(&obj);
diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c
index 040bbc7585..95e205a0ab 100644
--- a/tests/storagevolxml2xmltest.c
+++ b/tests/storagevolxml2xmltest.c
@@ -20,7 +20,7 @@ testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
     char *actual = NULL;
     int ret = -1;
     virStoragePoolDefPtr pool = NULL;
-    virStorageVolDefPtr dev = NULL;
+    VIR_AUTOPTR(virStorageVolDef) dev = NULL;
 
     if (!(pool = virStoragePoolDefParseFile(poolxml)))
         goto fail;
@@ -39,7 +39,6 @@ testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
  fail:
     VIR_FREE(actual);
     virStoragePoolDefFree(pool);
-    virStorageVolDefFree(dev);
     return ret;
 }
 
-- 
2.20.1


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux