After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 724609 - Fix build of GIO on Windows
Fix build of GIO on Windows
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
2.39.x
Other Windows
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2014-02-18 08:23 UTC by Fan, Chun-wei
Modified: 2014-02-23 03:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix build of handle_ip_address() on Windows (1.26 KB, patch)
2014-02-18 08:43 UTC, Fan, Chun-wei
needs-work Details | Review
Fix GOptionEntry array initialization on Visual C++ (1.12 KB, patch)
2014-02-18 08:46 UTC, Fan, Chun-wei
reviewed Details | Review
Fix build of handle_ip_address() on Windows (take ii) (1.41 KB, patch)
2014-02-19 06:00 UTC, Fan, Chun-wei
committed Details | Review
Simpler fix for building gio/gapplication.c (1.06 KB, patch)
2014-02-20 00:50 UTC, Fan, Chun-wei
committed Details | Review

Description Fan, Chun-wei 2014-02-18 08:23:52 UTC
Hi,

There were some recent changes (near the release of 2.39.90) to GIO which broke the build on Windows, one affects any Windows build, and the other is a MSVC-specific fix.  Patches to address these issues are attached in the following comments.
Comment 1 Fan, Chun-wei 2014-02-18 08:43:41 UTC
Created attachment 269510 [details] [review]
Fix build of handle_ip_address() on Windows

Hi,

This fixes the build of gio/gresolver.c as there isn't inet_aton() on Windows by using inet_addr() and checking whether it did not return successfully, otherwise reject the IPV4 address.
Comment 2 Fan, Chun-wei 2014-02-18 08:46:08 UTC
Created attachment 269511 [details] [review]
Fix GOptionEntry array initialization on Visual C++

Hi,

As Visual C++ is quite picky on the types used in a direct initialization of an array of structures, fix the build on Visual C++ by splitting up the initialization.  I know this is ugly, but it's how life goes here. :(

With blessings, thank you!
Comment 3 Dan Winship 2014-02-18 15:06:09 UTC
Comment on attachment 269510 [details] [review]
Fix build of handle_ip_address() on Windows

MSDN suggests that getaddrinfo() on Windows does not accept the non-standard IPv4 address formats, and so the extra check in handle_ip_address() is not needed.

(You could verify that with the "resolver" test program in gio/tests/. "./resolver 209.132.180.171" should return "Name: bugzilla-web.gnome.org", but "./resolver 209.132.46251" should return an error.)
Comment 4 Fan, Chun-wei 2014-02-19 06:00:12 UTC
Created attachment 269664 [details] [review]
Fix build of handle_ip_address() on Windows (take ii)

Hi Dan,

Thanks for the pointer, so this patch skips the check done by inet_aton(), as suggested, on Windows.

With blessings, thank you!
Comment 5 Dan Winship 2014-02-19 15:22:04 UTC
Comment on attachment 269664 [details] [review]
Fix build of handle_ip_address() on Windows (take ii)

>Windows already rejects non-standard and non-real IPv4 numers-and-dots
>addresses.

typo ("numers"). Otherwise fine
Comment 6 Dan Winship 2014-02-19 15:25:01 UTC
Comment on attachment 269511 [details] [review]
Fix GOptionEntry array initialization on Visual C++

>Visual C++ is quite zealous about checking against the types used in the
>initializing of array of structures

is this really a "type" thing? Or just that it doesn't allow non-constant array initializers? (Which weren't allowed in C90.)

>-      GOptionEntry my_entries[2] = { entries[i], { NULL } };
>+      GOptionEntry null_entry = { NULL };
>+      GOptionEntry my_entries[2];
>+
>+      my_entries[0] = entries[i];
>+      my_entries[1] = null_entry;

Do you actually need null_entry, or will this work:

    GOptionEntry my_entries[2] = { { NULL }, { NULL } };

    my_entries[0] = entries[i];

?
Comment 7 Fan, Chun-wei 2014-02-20 00:50:36 UTC
Created attachment 269741 [details] [review]
Simpler fix for building gio/gapplication.c

Hello Dan,

(In reply to comment #5) 
> typo ("numers"). Otherwise fine
oops :).  Pushed with typo fixed

(In reply to comment #6)
> (From update of attachment 269511 [details] [review])
> 
> is this really a "type" thing? Or just that it doesn't allow non-constant array
> initializers? (Which weren't allowed in C90.)

The errors I receive in the original code are:

error C2440: 'initializing' : Cannot convert 'const GOptionEntry' to 'const gchar *'
error C4047: 'initializing' : 'gchar' differs in levels of indirection from 'void *'

Even by using casts, there are still the C2440 errors, which is what made me believe that this is a type thing.

> Do you actually need null_entry, or will this work:
> 
>     GOptionEntry my_entries[2] = { { NULL }, { NULL } };
> 
>     my_entries[0] = entries[i];

Hmm, it does work.  So here's another patch for this.

With blesings, thank you!
Comment 8 Fan, Chun-wei 2014-02-23 03:51:08 UTC
Review of attachment 269741 [details] [review]:

Hello Dan,

Thanks for the reviews.  I have pushed this patch as 4825e819, and will close this bug shortly.

With blessings, thank you!