Re: [libvirt] [PATCH v1 19/40] util: pci: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC

2018-07-23 Thread Erik Skultety
On Sat, Jul 21, 2018 at 05:36:51PM +0530, Sukrit Bhatnagar wrote:
> Using the new VIR_DEFINE_AUTOPTR_FUNC macro defined in
> src/util/viralloc.h, define a new wrapper around an existing
> cleanup function which will be called when a variable declared
> with VIR_AUTOPTR macro goes out of scope. Also, drop the redundant
> viralloc.h include, since that has moved from the source module into
> the header.
>
> When variables of type virPCIDevicePtr and virPCIEDeviceInfoPtr
> are declared using VIR_AUTOPTR, the functions virPCIDeviceFree
> and virPCIEDeviceInfoFree, respectively, will be run automatically
> on them when they go out of scope.
>
> Signed-off-by: Sukrit Bhatnagar 
> ---

Reviewed-by: Erik Skultety 

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


[libvirt] [PATCH v1 19/40] util: pci: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC

2018-07-21 Thread Sukrit Bhatnagar
Using the new VIR_DEFINE_AUTOPTR_FUNC macro defined in
src/util/viralloc.h, define a new wrapper around an existing
cleanup function which will be called when a variable declared
with VIR_AUTOPTR macro goes out of scope. Also, drop the redundant
viralloc.h include, since that has moved from the source module into
the header.

When variables of type virPCIDevicePtr and virPCIEDeviceInfoPtr
are declared using VIR_AUTOPTR, the functions virPCIDeviceFree
and virPCIEDeviceInfoFree, respectively, will be run automatically
on them when they go out of scope.

Signed-off-by: Sukrit Bhatnagar 
---
 src/util/virpci.c | 1 -
 src/util/virpci.h | 4 
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index 8d02366..a606462 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -39,7 +39,6 @@
 
 #include "dirname.h"
 #include "virlog.h"
-#include "viralloc.h"
 #include "vircommand.h"
 #include "virerror.h"
 #include "virfile.h"
diff --git a/src/util/virpci.h b/src/util/virpci.h
index 794b7e5..8fc8716 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -28,6 +28,7 @@
 # include "virmdev.h"
 # include "virobject.h"
 # include "virutil.h"
+# include "viralloc.h"
 
 typedef struct _virPCIDevice virPCIDevice;
 typedef virPCIDevice *virPCIDevicePtr;
@@ -253,4 +254,7 @@ void virPCIEDeviceInfoFree(virPCIEDeviceInfoPtr dev);
 ssize_t virPCIGetMdevTypes(const char *sysfspath,
virMediatedDeviceType ***types);
 
+VIR_DEFINE_AUTOPTR_FUNC(virPCIDevice, virPCIDeviceFree)
+VIR_DEFINE_AUTOPTR_FUNC(virPCIEDeviceInfo, virPCIEDeviceInfoFree)
+
 #endif /* __VIR_PCI_H__ */
-- 
1.8.3.1

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