Use 'offsetof' to avoid undefined behavior.
authorMark H Weaver <mhw@netris.org>
Wed, 12 Mar 2014 00:31:38 +0000 (20:31 -0400)
committerMark H Weaver <mhw@netris.org>
Wed, 12 Mar 2014 01:39:20 +0000 (21:39 -0400)
* libguile/socket.c (SUN_LEN): Use 'offsetof'.

libguile/socket.c

index c0faae1..5b17a74 100644 (file)
@@ -64,7 +64,7 @@
 
 
 #if defined (HAVE_UNIX_DOMAIN_SOCKETS) && !defined (SUN_LEN)
-#define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
+#define SUN_LEN(ptr) (offsetof (struct sockaddr_un, sun_path) \
                      + strlen ((ptr)->sun_path))
 #endif