From: Paul Eggert Date: Wed, 17 May 2017 17:27:31 +0000 (-0700) Subject: Catch IPv4/IPv6 issues at compile time X-Git-Tag: emacs-26.0.90~521^2~380 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=937ff1a0af1813875f851987ca5c4ac833ca3c97;p=emacs.git Catch IPv4/IPv6 issues at compile time * src/process.c (connect_network_socket): Use verify, not eassert, so that any problems are caught at compile-time. Avoid dodgy cast by using a local var of the correct type. --- diff --git a/src/process.c b/src/process.c index ecb1b0ca6df..8180feaba9a 100644 --- a/src/process.c +++ b/src/process.c @@ -3430,11 +3430,11 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, /* The code below assumes the port is at the same offset and of the same width in both IPv4 and IPv6 structures, but the standards don't guarantee that, - so we have this assertion to make sure. */ - eassert ((offsetof (struct sockaddr_in, sin_port) - == offsetof (struct sockaddr_in6, sin6_port)) - && (sizeof (sa1.sin_port) - == sizeof (((struct sockaddr_in6 *) &sa1)->sin6_port))); + so verify it here. */ + struct sockaddr_in6 sa6; + verify ((offsetof (struct sockaddr_in, sin_port) + == offsetof (struct sockaddr_in6, sin6_port)) + && sizeof (sa1.sin_port) == sizeof (sa6.sin6_port)); #endif if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0) {