[libvirt] [PATCH v2 09/32] conf: Introduce VIR_DEFINE_AUTOPTR_FUNC for virStoragePoolDef

Ján Tomko jtomko at redhat.com
Mon Feb 11 12:08:18 UTC 2019


On Fri, Feb 08, 2019 at 01:37:03PM -0500, John Ferlan wrote:
>Let's make use of the auto __cleanup capabilities cleaning up any
>now unnecessary goto paths.
>
>Signed-off-by: John Ferlan <jferlan at redhat.com>
>Reviewed-by: Erik Skultety <eskultet at redhat.com>
>---
> src/conf/domain_conf.c             |  3 +--
> src/conf/storage_conf.c            |  3 +--
> src/conf/storage_conf.h            |  1 +
> src/conf/virstorageobj.c           | 27 +++++++++++----------------
> src/phyp/phyp_driver.c             |  3 +--
> src/storage/storage_driver.c       |  6 ++----
> src/test/test_driver.c             |  6 ++----
> tests/storagebackendsheepdogtest.c |  6 ++----
> tests/storagepoolxml2xmltest.c     |  3 +--
> tests/storagevolxml2argvtest.c     |  3 +--
> tests/storagevolxml2xmltest.c      |  3 +--
> 11 files changed, 24 insertions(+), 40 deletions(-)
>
>diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
>index cac5642afd..dc082b1d08 100644
>--- a/src/phyp/phyp_driver.c
>+++ b/src/phyp/phyp_driver.c
>@@ -1952,11 +1952,11 @@ phypStorageVolCreateXML(virStoragePoolPtr pool,
> {
>     virCheckFlags(0, NULL);
>
>-    virStoragePoolDefPtr spdef = NULL;
>     virStorageVolPtr vol = NULL;
>     virStorageVolPtr dup_vol = NULL;
>     char *key = NULL;
>     VIR_AUTOPTR(virStorageVolDef) voldef = NULL;
>+    VIR_AUTOPTR(virStoragePoolDef) spdef = NULL;
>
>     if (VIR_ALLOC(spdef) < 0)
>         return NULL;
>@@ -2036,7 +2036,6 @@ phypStorageVolCreateXML(virStoragePoolPtr pool,
>
>  err:
>     VIR_FREE(key);
>-    virStoragePoolDefFree(spdef);

It seems spdef was leaked on success in this function before this patch.

>     virObjectUnref(vol);
>     return NULL;
> }

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190211/dbafe85a/attachment-0001.sig>


More information about the libvir-list mailing list