summaryrefslogtreecommitdiff
path: root/ext/socket/tcpserver.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-24 17:51:17 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-24 17:51:17 +0000
commitc89844dbc50c1422774c39b03e0757c91531e586 (patch)
tree6b025765ef5e602e8d11c3c83b11ed7d5c9361ea /ext/socket/tcpserver.c
parentef339580947c7df1281263ccfb99718887e5378d (diff)
* ext/socket: define and use union_sockaddr instead of struct
sockaddr_storage for less casts. * ext/socket/rubysocket.h (union_sockaddr): defined. * ext/socket/socket.c (sock_accept): use union_sockaddr. (sock_accept_nonblock): ditto. (sock_sysaccept): ditto. (sock_s_getnameinfo): ditto. * ext/socket/basicsocket.c (bsock_getsockname): ditto. (bsock_getpeername): ditto. (bsock_local_address): ditto. (bsock_remote_address): ditto. * ext/socket/ancdata.c (bsock_recvmsg_internal): ditto. * ext/socket/init.c (recvfrom_arg): ditto. (recvfrom_blocking): ditto. (rsock_s_recvfrom): ditto. (rsock_s_recvfrom_nonblock): ditto. (rsock_getfamily): ditto. * ext/socket/raddrinfo.c (rb_addrinfo_t): ditto. (ai_get_afamily): ditto. (inspect_sockaddr): ditto. (addrinfo_mdump): ditto. (addrinfo_mload): ditto. (addrinfo_getnameinfo): ditto. (addrinfo_ip_port): ditto. (extract_in_addr): ditto. (addrinfo_ipv6_to_ipv4): ditto. (addrinfo_unix_path): ditto. * ext/socket/tcpserver.c (tcp_accept): ditto. (tcp_accept_nonblock): ditto. (tcp_sysaccept): ditto. * ext/socket/ipsocket.c (ip_addr): ditto. (ip_peeraddr): ditto. (ip_s_getaddress): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/tcpserver.c')
-rw-r--r--ext/socket/tcpserver.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/ext/socket/tcpserver.c b/ext/socket/tcpserver.c
index 6596733..317470a 100644
--- a/ext/socket/tcpserver.c
+++ b/ext/socket/tcpserver.c
@@ -47,13 +47,12 @@ static VALUE
tcp_accept(VALUE sock)
{
rb_io_t *fptr;
- struct sockaddr_storage from;
+ union_sockaddr from;
socklen_t fromlen;
GetOpenFile(sock, fptr);
fromlen = (socklen_t)sizeof(from);
- return rsock_s_accept(rb_cTCPSocket, fptr->fd,
- (struct sockaddr*)&from, &fromlen);
+ return rsock_s_accept(rb_cTCPSocket, fptr->fd, &from.addr, &fromlen);
}
/*
@@ -93,13 +92,12 @@ static VALUE
tcp_accept_nonblock(VALUE sock)
{
rb_io_t *fptr;
- struct sockaddr_storage from;
+ union_sockaddr from;
socklen_t fromlen;
GetOpenFile(sock, fptr);
fromlen = (socklen_t)sizeof(from);
- return rsock_s_accept_nonblock(rb_cTCPSocket, fptr,
- (struct sockaddr *)&from, &fromlen);
+ return rsock_s_accept_nonblock(rb_cTCPSocket, fptr, &from.addr, &fromlen);
}
/*
@@ -120,12 +118,12 @@ static VALUE
tcp_sysaccept(VALUE sock)
{
rb_io_t *fptr;
- struct sockaddr_storage from;
+ union_sockaddr from;
socklen_t fromlen;
GetOpenFile(sock, fptr);
fromlen = (socklen_t)sizeof(from);
- return rsock_s_accept(0, fptr->fd, (struct sockaddr*)&from, &fromlen);
+ return rsock_s_accept(0, fptr->fd, &from.addr, &fromlen);
}
void