[libvirt] [PATCH v3 28/35] util: bitmap: use VIR_AUTOPTR for aggregate types

Sukrit Bhatnagar posted 35 patches 6 years, 10 months ago
There is a newer version of this series
[libvirt] [PATCH v3 28/35] util: bitmap: use VIR_AUTOPTR for aggregate types
Posted by Sukrit Bhatnagar 6 years, 10 months ago
By making use of GNU C's cleanup attribute handled by the
VIR_AUTOPTR macro for declaring aggregate pointer variables,
majority of the calls to *Free functions can be dropped, which
in turn leads to getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
---
 src/util/virbitmap.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index ef18dad..5b6e55f 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -1202,15 +1202,12 @@ char *
 virBitmapDataFormat(const void *data,
                     int len)
 {
-    virBitmapPtr map = NULL;
-    char *ret = NULL;
+    VIR_AUTOPTR(virBitmap) map = NULL;
 
     if (!(map = virBitmapNewData(data, len)))
         return NULL;
 
-    ret = virBitmapFormat(map);
-    virBitmapFree(map);
-    return ret;
+    return virBitmapFormat(map);
 }
 
 
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 28/35] util: bitmap: use VIR_AUTOPTR for aggregate types
Posted by Erik Skultety 6 years, 10 months ago
On Sat, Jun 30, 2018 at 02:30:32PM +0530, Sukrit Bhatnagar wrote:
> By making use of GNU C's cleanup attribute handled by the
> VIR_AUTOPTR macro for declaring aggregate pointer variables,
> majority of the calls to *Free functions can be dropped, which
> in turn leads to getting rid of most of our cleanup sections.
>
> Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
> ---
Reviewed-by: Erik Skultety <eskultet@redhat.com>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list