[libvirt] [PATCH] fix MinGW compilation(200808)

Jim Meyering jim at meyering.net
Wed Aug 6 07:10:04 UTC 2008


"Daniel P. Berrange" <berrange at redhat.com> wrote:
> On Tue, Aug 05, 2008 at 01:52:58PM +0200, Jim Meyering wrote:
>> Atsushi SAKAI <sakaia at jp.fujitsu.com> wrote:
>> ...
>> > network_conf.c:290: warning: implicit declaration of function `inet_aton'
>> > network_conf.c:290: warning: nested extern declaration of `inet_aton'
>>
>> We can/should use inet_pton instead.  Then, not only do we use what seems
>> to be the preferred interface, but there is a gnulib module by the same
>> name that can come into play if it too is missing.
>
> Even better would be to use  getaddrinfo() with AI_NUMERIC, since we
> already require getaddrinfo() to work on Windows for the remote driver

Dan,

If you don't object, I'll go for the simpler interface (and smaller
change).  However I've just noticed that that will require an adjustment
of the gnulib license for the inet_pton module.  But that shouldn't be
a problem, since the code in question is glibc-derived.

Here's the required patch, excluding the bit that will
add the new file(s) from gnulib, once the license has
been adjusted.

diff --git a/bootstrap b/bootstrap
index bc1c352..70b9a05 100755
--- a/bootstrap
+++ b/bootstrap
@@ -69,6 +69,7 @@ c-ctype
 getaddrinfo
 getpass
 gettext
+inet_pton
 mktempd
 physmem
 poll
diff --git a/src/network_conf.c b/src/network_conf.c
index 10c9dca..8c8a366 100644
--- a/src/network_conf.c
+++ b/src/network_conf.c
@@ -286,13 +286,13 @@ virNetworkDefParseXML(virConnectPtr conn,
         char *netaddr;
         xmlNodePtr dhcp;

-        if (!inet_aton(def->ipAddress, &inaddress)) {
+        if (inet_pton(AF_INET, def->ipAddress, &inaddress) <= 0) {
             virNetworkReportError(conn, VIR_ERR_INTERNAL_ERROR,
                                   _("cannot parse IP address '%s'"),
                                   def->ipAddress);
             goto error;
         }
-        if (!inet_aton(def->netmask, &innetmask)) {
+        if (!inet_pton(AF_INET, def->netmask, &innetmask) <= 0) {
             virNetworkReportError(conn, VIR_ERR_INTERNAL_ERROR,
                                   _("cannot parse netmask '%s'"),
                                   def->netmask);




More information about the libvir-list mailing list