tests/server/util: remove in6addr_any for recent MinGW #1379

Merged
merged 1 commit into from Apr 3, 2017

Projects

None yet

4 participants

@MarcelRaad
Member
MarcelRaad commented Apr 2, 2017 edited

In ancient MinGW versions, in6addr_any was declared as extern, but not
defined. Because of that, 22a0c57 added
definitions for in6addr_any when compiling with MinGW. The bug was fixed in
w32api version 3.6 from 2006, so this workaround is not needed anymore for
recent versions.

This fixes the following MinGW-w64 warnings because the MinGW-w64 version of
IN6ADDR_ANY_INIT has the two additional braces inside the macro:
util.c:59:14: warning: braces around scalar initializer
util.c:59:40: warning: excess elements in scalar initializer

Ref: https://sourceforge.net/p/mingw/mingw-org-wsl/ci/e4803e0da25c57ae1ad0fa75ae2b7182ff7fa339/tree/w32api/ChangeLog

An alternative would be to remove support for these ancient MinGW versions
and just remove the redefinition of inaddr_any, of course.

@MarcelRaad, thanks for your PR! By analyzing the history of the files in this pull request, we identified @yangtse, @bagder and @gknauf to be potential reviewers.

#if defined(ENABLE_IPV6) && defined(__MINGW32__)
+#if (__W32API_MAJOR_VERSION < 3) || \
+ ((__W32API_MAJOR_VERSION == 3) && (__W32API_MINOR_VERSION < 6))
const struct in6_addr in6addr_any = {{ IN6ADDR_ANY_INIT }};
jay
jay Apr 2, 2017 Owner

mingw-w64 mingw-w64-headers/include/ws2tcpip.h:

#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }

libcurl tests/server/util.c:

const struct in6_addr in6addr_any = {{ IN6ADDR_ANY_INIT }};

The extra braces appear to have been added to util.c in 14424f7. Original mingw defines that macro as {0} and it has to be {{{0}}} to avoid a missing braces warning at some levels.

Re fix, it's fine but the comment is superfluous since the check makes it obvious.

@bagder
bagder approved these changes Apr 2, 2017 View changes
@MarcelRaad MarcelRaad tests/server/util: remove in6addr_any for recent MinGW
In ancient MinGW versions, in6addr_any was declared as extern, but not
defined. Because of that, 22a0c57 added
definitions for in6addr_any when compiling with MinGW. The bug was fixed in
w32api version 3.6 from 2006, so this workaround is not needed anymore for
recent versions.

This fixes the following MinGW-w64 warnings because the MinGW-w64 version of
IN6ADDR_ANY_INIT has the two additional braces inside the macro:
util.c:59:14: warning: braces around scalar initializer
util.c:59:40: warning: excess elements in scalar initializer

Ref: https://sourceforge.net/p/mingw/mingw-org-wsl/ci/e4803e0da25c57ae1ad0fa75ae2b7182ff7fa339/tree/w32api/ChangeLog
Closes curl#1379
55f4aba
@MarcelRaad MarcelRaad merged commit 55f4aba into curl:master Apr 3, 2017

0 of 3 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details
@MarcelRaad MarcelRaad deleted the MarcelRaad:util_initializer branch Apr 3, 2017
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment