diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2017-04-25 13:08:52 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2017-04-25 13:08:52 (GMT) |
commit | fa02e7f947236f2d780798ba13956209e355036e (patch) | |
tree | 1e469a22e35b12895ef4930dab953167033dcd76 /unix/tclUnixSock.c | |
parent | 2507a22c1331a14e20f89bc665f8f8f0810d8da8 (diff) | |
download | tcl-fa02e7f947236f2d780798ba13956209e355036e.zip tcl-fa02e7f947236f2d780798ba13956209e355036e.tar.gz tcl-fa02e7f947236f2d780798ba13956209e355036e.tar.bz2 |
Deal with a couple of obscure causes of warnings on some versions of OSX.
Diffstat (limited to 'unix/tclUnixSock.c')
-rw-r--r-- | unix/tclUnixSock.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c index ca8d677..e8767e2 100644 --- a/unix/tclUnixSock.c +++ b/unix/tclUnixSock.c @@ -698,6 +698,33 @@ TcpClose2Proc( * *---------------------------------------------------------------------- */ + +#ifndef NEED_FAKE_RFC2553 +static inline int +IPv6AddressNeedsNumericRendering( + struct in6_addr addr) +{ + if (IN6_ARE_ADDR_EQUAL(&addr, &in6addr_any)) { + return 1; + } + + /* + * The IN6_IS_ADDR_V4MAPPED macro has a problem with aliasing warnings on + * at least some versions of OSX. + */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" + if (!IN6_IS_ADDR_V4MAPPED(&addr)) { +#pragma GCC diagnostic pop + return 0; + } + + return (addr.s6_addr[12] == 0 && addr.s6_addr[13] == 0 + && addr.s6_addr[14] == 0 && addr.s6_addr[15] == 0); +} +#endif /* NEED_FAKE_RFC2553 */ + static void TcpHostPortList( Tcl_Interp *interp, @@ -723,13 +750,7 @@ TcpHostPortList( } #ifndef NEED_FAKE_RFC2553 } else if (addr.sa.sa_family == AF_INET6) { - if ((IN6_ARE_ADDR_EQUAL(&addr.sa6.sin6_addr, - &in6addr_any)) - || (IN6_IS_ADDR_V4MAPPED(&addr.sa6.sin6_addr) && - addr.sa6.sin6_addr.s6_addr[12] == 0 && - addr.sa6.sin6_addr.s6_addr[13] == 0 && - addr.sa6.sin6_addr.s6_addr[14] == 0 && - addr.sa6.sin6_addr.s6_addr[15] == 0)) { + if (IPv6AddressNeedsNumericRendering(addr.sa6.sin6_addr)) { flags |= NI_NUMERICHOST; } #endif /* NEED_FAKE_RFC2553 */ |