Commit e562a61a introduced new function to get/set interface state but there was misuse of ATTRIBUTE_NONNULL on non-pointer attributes and also we need to wrap that functions by #ifdef to not break mingw build. Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- src/util/virnetdev.c | 36 ++++++++++++++++++++++++------------ src/util/virnetdev.h | 6 +++--- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 4be6265..315c431 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -66,6 +66,18 @@ VIR_LOG_INIT("util.netdev"); #define VIR_MCAST_TOKEN_DELIMS " \n" #define VIR_MCAST_ADDR_LEN (VIR_MAC_HEXLEN + 1) +#if defined(SIOCSIFFLAGS) && defined(HAVE_STRUCT_IFREQ) +# define VIR_IFF_UP IFF_UP +# define VIR_IFF_PROMISC IFF_PROMISC +# define VIR_IFF_MULTICAST IFF_MULTICAST +# define VIR_IFF_ALLMULTI IFF_ALLMULTI +#else +# define VIR_IFF_UP 0 +# define VIR_IFF_PROMISC 0 +# define VIR_IFF_MULTICAST 0 +# define VIR_IFF_ALLMULTI 0 +#endif + typedef enum { VIR_MCAST_TYPE_INDEX_TOKEN, VIR_MCAST_TYPE_NAME_TOKEN, @@ -677,7 +689,7 @@ int virNetDevSetOnline(const char *ifname, bool online) { - return virNetDevSetIFFlag(ifname, IFF_UP, online); + return virNetDevSetIFFlag(ifname, VIR_IFF_UP, online); } /** @@ -694,7 +706,7 @@ int virNetDevSetOnline(const char *ifname, int virNetDevSetPromiscuous(const char *ifname, bool promiscuous) { - return virNetDevSetIFFlag(ifname, IFF_PROMISC, promiscuous); + return virNetDevSetIFFlag(ifname, VIR_IFF_PROMISC, promiscuous); } /** @@ -712,7 +724,7 @@ int virNetDevSetPromiscuous(const char *ifname, int virNetDevSetRcvMulti(const char *ifname, bool receive) { - return virNetDevSetIFFlag(ifname, IFF_MULTICAST, receive); + return virNetDevSetIFFlag(ifname, VIR_IFF_MULTICAST, receive); } /** @@ -728,7 +740,7 @@ int virNetDevSetRcvMulti(const char *ifname, int virNetDevSetRcvAllMulti(const char *ifname, bool receive) { - return virNetDevSetIFFlag(ifname, IFF_ALLMULTI, receive); + return virNetDevSetIFFlag(ifname, VIR_IFF_ALLMULTI, receive); } @@ -783,7 +795,7 @@ virNetDevGetIFFlag(const char *ifname, int virNetDevGetOnline(const char *ifname, bool *online) { - return virNetDevGetIFFlag(ifname, IFF_UP, online); + return virNetDevGetIFFlag(ifname, VIR_IFF_UP, online); } /** @@ -797,9 +809,9 @@ int virNetDevGetOnline(const char *ifname, * Returns 0 in case of success or an errno code in case of failure. */ int virNetDevGetPromiscuous(const char *ifname, - bool *promiscuous) + bool *promiscuous) { - return virNetDevGetIFFlag(ifname, IFF_PROMISC, promiscuous); + return virNetDevGetIFFlag(ifname, VIR_IFF_PROMISC, promiscuous); } /** @@ -813,9 +825,9 @@ int virNetDevGetPromiscuous(const char *ifname, * Returns 0 in case of success or -1 on error. */ int virNetDevGetRcvMulti(const char *ifname, - bool *receive) + bool *receive) { - return virNetDevGetIFFlag(ifname, IFF_MULTICAST, receive); + return virNetDevGetIFFlag(ifname, VIR_IFF_MULTICAST, receive); } /** @@ -829,9 +841,9 @@ int virNetDevGetRcvMulti(const char *ifname, * Returns 0 in case of success or -1 on error. */ int virNetDevGetRcvAllMulti(const char *ifname, - bool *receive) + bool *receive) { - return virNetDevGetIFFlag(ifname, IFF_ALLMULTI, receive); + return virNetDevGetIFFlag(ifname, VIR_IFF_ALLMULTI, receive); } @@ -2668,7 +2680,7 @@ int virNetDevGetRxFilter(const char *ifname, virNetDevRxFilterPtr *filter) { int ret = -1; - bool receive; + bool receive = false; virNetDevRxFilterPtr fil = virNetDevRxFilterNew(); if (!fil) diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h index 6e8372f..de8b480 100644 --- a/src/util/virnetdev.h +++ b/src/util/virnetdev.h @@ -201,17 +201,17 @@ int virNetDevDelMulti(const char *ifname, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; int virNetDevSetPromiscuous(const char *ifname, bool promiscuous) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; + ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; int virNetDevGetPromiscuous(const char *ifname, bool *promiscuous) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; int virNetDevSetRcvMulti(const char *ifname, bool receive) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; + ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; int virNetDevGetRcvMulti(const char *ifname, bool *receive) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; int virNetDevSetRcvAllMulti(const char *ifname, bool receive) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; + ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; int virNetDevGetRcvAllMulti(const char *ifname, bool *receive) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; #endif /* __VIR_NETDEV_H__ */ -- 2.0.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list