summaryrefslogtreecommitdiff
path: root/ext/socket/sockport.h
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-14 23:14:22 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-14 23:14:22 +0000
commit1ff7108306f63b1f5cc9b0ed2d376f5a1f99bdf4 (patch)
treee6311f2f125a7bb6cf043e67dee4cf3e0ea02eb5 /ext/socket/sockport.h
parentdfbb5b677c1b293e0177bc99b2d7dcf24e87453d (diff)
* ext/socket/sockport.h (SET_SS_LEN): removed.
(SET_SIN_LEN): removed. (INIT_SOCKADDR): new macro. * ext/socket/ancdata.c (extract_ipv6_pktinfo): use INIT_SOCKADDR. * ext/socket/raddrinfo.c (make_inetaddr): use INIT_SOCKADDR. (addrinfo_ipv6_to_ipv4): ditto. * ext/socket/getaddrinfo.c (GET_AI): use INIT_SOCKADDR. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/sockport.h')
-rw-r--r--ext/socket/sockport.h15
1 files changed, 8 insertions, 7 deletions
diff --git a/ext/socket/sockport.h b/ext/socket/sockport.h
index 1e01bce..517b8f7 100644
--- a/ext/socket/sockport.h
+++ b/ext/socket/sockport.h
@@ -18,17 +18,18 @@
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
# define SET_SA_LEN(sa, len) (void)((sa)->sa_len = (len))
-# define SET_SS_LEN(ss, len) (void)((ss)->ss_len = (len))
#else
# define SET_SA_LEN(sa, len) (void)(len)
-# define SET_SS_LEN(ss, len) (void)(len)
#endif
-#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
-# define SET_SIN_LEN(si,len) (si)->sin_len = (len)
-#else
-# define SET_SIN_LEN(si,len)
-#endif
+#define INIT_SOCKADDR(addr, family, len) \
+ do { \
+ struct sockaddr *init_sockaddr_ptr = (addr); \
+ socklen_t init_sockaddr_len = (len); \
+ memset(init_sockaddr_ptr, 0, init_sockaddr_len); \
+ init_sockaddr_ptr->sa_family = (family); \
+ SET_SA_LEN(init_sockaddr_ptr, init_sockaddr_len); \
+ } while (0)
#ifndef IN_MULTICAST
# define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)