[libvirt] [PATCH 0/2] fix build issues found by MinGW and Coverity

Pavel Hrdina (2): virnetdev: fix some issues found by coverity and mingw builds virutil: fix MinGW build src/util/virnetdev.c | 36 ++++++++++++++++++++++++------------ src/util/virnetdev.h | 6 +++--- src/util/virutil.c | 8 ++++++++ 3 files changed, 35 insertions(+), 15 deletions(-) -- 2.0.5

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@redhat.com> --- 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

On 02/03/2015 08:27 AM, Pavel Hrdina wrote:
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@redhat.com> --- 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 +
Sigh. I should have noticed this when I sent the patch making virNetDev[GS]etIFFlag static - I even mentioned that I wanted to *avoid* the need to define our own private versions of the flags, but was too dense to realize that we *already* needed to do that :-/ One fine pedantic point - if it were to every happen that a platform had SIOCGIFFLAGS but not SIOCSIFFLAGS, the incorrect values would be defined for VIR_IFF_*. Since that is *never* going to happen, and since the alternative of using "#if defined(IFF_UP)..." could lead to silently misdefined values if some platform only had enum values for IFF_* but no #defines, I think the way you've done it is the best option.
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) {
As long as you're touching all of these very short functions, can you also reformat the first lines of all of them to have the return type on a separate line from the function name?
- 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();
I assume that the above was done to silence a coverity error, since receive is definitely never used before it is set. Assuming that, ACK (with the first lines of all the functions split, as requested above).
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__ */

On 02/03/2015 03:48 PM, Laine Stump wrote:
On 02/03/2015 08:27 AM, Pavel Hrdina wrote:
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@redhat.com> --- 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 +
Sigh. I should have noticed this when I sent the patch making virNetDev[GS]etIFFlag static - I even mentioned that I wanted to *avoid* the need to define our own private versions of the flags, but was too dense to realize that we *already* needed to do that :-/
One fine pedantic point - if it were to every happen that a platform had SIOCGIFFLAGS but not SIOCSIFFLAGS, the incorrect values would be defined for VIR_IFF_*. Since that is *never* going to happen, and since the alternative of using "#if defined(IFF_UP)..." could lead to silently misdefined values if some platform only had enum values for IFF_* but no #defines, I think the way you've done it is the best option.
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) {
As long as you're touching all of these very short functions, can you also reformat the first lines of all of them to have the return type on a separate line from the function name?
Sure, I can do that too. I was wandering whether to also update that and I told myself that it would be probably better to unify that formatting globally for the whole libvirt code.
- 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();
I assume that the above was done to silence a coverity error, since receive is definitely never used before it is set.
Assuming that, ACK (with the first lines of all the functions split, as requested above).
Actually MinGW was unhappy about this. Thanks for review. I'll update the commit and push it. Pavel
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__ */

On Tue, Feb 03, 2015 at 02:27:34PM +0100, Pavel Hrdina wrote:
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@redhat.com> --- src/util/virnetdev.c | 36 ++++++++++++++++++++++++------------ src/util/virnetdev.h | 6 +++--- 2 files changed, 27 insertions(+), 15 deletions(-)
ACK Jan

Commit b38da584 introduced two new functions to get a page size but it won't work on Windows. We should take care of this. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/util/virutil.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/util/virutil.c b/src/util/virutil.c index c905209..06e608d 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -2578,10 +2578,18 @@ virGetListenFDs(void) #endif /* WIN32 */ +#ifndef WIN32 long virGetSystemPageSize(void) { return sysconf(_SC_PAGESIZE); } +#else /* WIN32 */ +long virGetSystemPageSize(void) +{ + virReportSystemError(ENOSYS, "%s", _("Not supported on this platform")); + return -1; +} +#endif /* WIN32 */ long virGetSystemPageSizeKB(void) { -- 2.0.5

On Tue, Feb 03, 2015 at 02:27:35PM +0100, Pavel Hrdina wrote:
Commit b38da584 introduced two new functions to get a page size but it won't work on Windows. We should take care of this.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/util/virutil.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/src/util/virutil.c b/src/util/virutil.c index c905209..06e608d 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -2578,10 +2578,18 @@ virGetListenFDs(void)
#endif /* WIN32 */
+#ifndef WIN32 long virGetSystemPageSize(void) { return sysconf(_SC_PAGESIZE); } +#else /* WIN32 */ +long virGetSystemPageSize(void) +{ + virReportSystemError(ENOSYS, "%s", _("Not supported on this platform"));
The non-win32 version of this does not set a libvirt error, so errno = ENOSYS; should be enough. But the function won't get executed anyway. ACK Jan
+ return -1; +} +#endif /* WIN32 */
long virGetSystemPageSizeKB(void) { -- 2.0.5
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 02/03/2015 03:54 PM, Ján Tomko wrote:
On Tue, Feb 03, 2015 at 02:27:35PM +0100, Pavel Hrdina wrote:
Commit b38da584 introduced two new functions to get a page size but it won't work on Windows. We should take care of this.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/util/virutil.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/src/util/virutil.c b/src/util/virutil.c index c905209..06e608d 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -2578,10 +2578,18 @@ virGetListenFDs(void)
#endif /* WIN32 */
+#ifndef WIN32 long virGetSystemPageSize(void) { return sysconf(_SC_PAGESIZE); } +#else /* WIN32 */ +long virGetSystemPageSize(void) +{ + virReportSystemError(ENOSYS, "%s", _("Not supported on this platform"));
The non-win32 version of this does not set a libvirt error, so errno = ENOSYS; should be enough.
I'll update that, thanks. Pavel
But the function won't get executed anyway.
ACK
Jan
+ return -1; +} +#endif /* WIN32 */
long virGetSystemPageSizeKB(void) { -- 2.0.5
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 02/03/2015 06:27 AM, Pavel Hrdina wrote:
Commit b38da584 introduced two new functions to get a page size but it won't work on Windows. We should take care of this.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/util/virutil.c | 8 ++++++++ 1 file changed, 8 insertions(+)
+#else /* WIN32 */ +long virGetSystemPageSize(void) +{ + virReportSystemError(ENOSYS, "%s", _("Not supported on this platform")); + return -1; +} +#endif /* WIN32 */
Instead of giving up completely, we should probably copy what qemu uses: size_t getpagesize(void) { SYSTEM_INFO system_info; GetSystemInfo(&system_info); return system_info.dwPageSize; } -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (4)
-
Eric Blake
-
Ján Tomko
-
Laine Stump
-
Pavel Hrdina