Re: [PATCH v1 05/32] util: netdev: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC

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

 



On Sat, Jul 28, 2018 at 11:31:20PM +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 virNetDevRxFilterPtr and virNetDevMcastEntryPtr
> are declared using VIR_AUTOPTR, the functions virNetDevRxFilterFree
> and virNetDevMcastEntryFree, respectively, will be run
> automatically on them when they go out of scope.
> 
> Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@xxxxxxxxx>
> ---
>  src/util/virnetdev.c | 9 ++++++++-
>  src/util/virnetdev.h | 4 ++++
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
> index 0777eca..9eca786 100644
> --- a/src/util/virnetdev.c
> +++ b/src/util/virnetdev.c
> @@ -29,7 +29,6 @@
>  #include "virfile.h"
>  #include "virerror.h"
>  #include "vircommand.h"
> -#include "viralloc.h"
>  #include "virpci.h"
>  #include "virlog.h"
>  #include "virstring.h"
> @@ -120,6 +119,14 @@ struct _virNetDevMcastEntry  {
>          virMacAddr macaddr;
>  };
>  
> +static void
> +virNetDevMcastEntryFree(virNetDevMcastEntryPtr entry)
> +{
> +    VIR_FREE(entry);
> +}
> +
> +VIR_DEFINE_AUTOPTR_FUNC(virNetDevMcastEntry, virNetDevMcastEntryFree)

This causes a compile problem on non-linux platforms due to the function
being unused:

util/virnetdev.c:128:1: error: unused function 'virNetDevMcastEntryAutoPtrFree' [-Werror,-Wunused-function]
VIR_DEFINE_AUTOPTR_FUNC(virNetDevMcastEntry, virNetDevMcastEntryFree)
^
./util/viralloc.h:612:24: note: expanded from macro 'VIR_DEFINE_AUTOPTR_FUNC'
    static inline void VIR_AUTOPTR_FUNC_NAME(type)(type **_ptr) \
                       ^
./util/viralloc.h:600:38: note: expanded from macro 'VIR_AUTOPTR_FUNC_NAME'
# define VIR_AUTOPTR_FUNC_NAME(type) type##AutoPtrFree
                                     ^
<scratch space>:21:1: note: expanded from here
virNetDevMcastEntryAutoPtrFree
^
1 error generated.




Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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



[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