On 08/13/2018 07:42 AM, Erik Skultety wrote:
On Thu, Aug 09, 2018 at 09:42:10AM +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.
>
> This commit also typedefs virNlMsg to struct nl_msg type for use
> with the cleanup macros.
>
> When a variable of type virNlMsg * is declared using VIR_AUTOPTR,
> the function nlmsg_free will be run automatically on it when it
> goes out of scope.
>
> Signed-off-by: Sukrit Bhatnagar <skrtbhtngr(a)gmail.com>
> ---
> src/util/virnetlink.c | 1 -
> src/util/virnetlink.h | 5 +++++
> 2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
> index 162efe6..ecf62c9 100644
> --- a/src/util/virnetlink.c
> +++ b/src/util/virnetlink.c
> @@ -38,7 +38,6 @@
> #include "virnetlink.h"
> #include "virnetdev.h"
> #include "virlog.h"
> -#include "viralloc.h"
> #include "virthread.h"
> #include "virmacaddr.h"
> #include "virerror.h"
> diff --git a/src/util/virnetlink.h b/src/util/virnetlink.h
> index 2a9de0a..8ebeab8 100644
> --- a/src/util/virnetlink.h
> +++ b/src/util/virnetlink.h
> @@ -22,6 +22,7 @@
>
> # include "internal.h"
> # include "virmacaddr.h"
> +# include "viralloc.h"
>
> # if defined(__linux__) && defined(HAVE_LIBNL)
>
> @@ -44,6 +45,8 @@ struct nlmsghdr;
>
> # endif /* __linux__ */
>
> +typedef struct nl_msg virNlMsg;
Since the name of the module is virNetlink, I'll rename this to virNetlinkMsg
and tweak all the affected places across the whole series.
Reviewed-by: Erik Skultety <eskultet(a)redhat.com>
> +
> int virNetlinkStartup(void);
> void virNetlinkShutdown(void);
>
> @@ -123,4 +126,6 @@ int virNetlinkEventAddClient(virNetlinkEventHandleCallback
handleCB,
> int virNetlinkEventRemoveClient(int watch, const virMacAddr *macaddr,
> unsigned int protocol);
>
> +VIR_DEFINE_AUTOPTR_FUNC(virNlMsg, nlmsg_free)
> +
The freebsd builds are not very happy, for example from...
https://ci.centos.org/view/libvirt/job/libvirt-master-build/systems=libvi...
One gets:
...
CC util/libvirt_nss_la-viratomic.lo
In file included from ../../src/network/bridge_driver.c:63:
../../src/util/virnetlink.h:129:40: error: use of undeclared identifier
'nlmsg_free'
VIR_DEFINE_AUTOPTR_FUNC(virNetlinkMsg, nlmsg_free)
^
1 error generated.
John
> #endif /* __VIR_NETLINK_H__ */
> --
> 1.8.3.1
>
> --
> libvir-list mailing list
> libvir-list(a)redhat.com
>
https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list