emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 937ff1a 2/3: Catch IPv4/IPv6 issues at compile time


From: Paul Eggert
Subject: [Emacs-diffs] master 937ff1a 2/3: Catch IPv4/IPv6 issues at compile time
Date: Wed, 17 May 2017 13:59:08 -0400 (EDT)

branch: master
commit 937ff1a0af1813875f851987ca5c4ac833ca3c97
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    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.
---
 src/process.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/process.c b/src/process.c
index ecb1b0c..8180fea 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)
                {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]