mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/raddrinfo.c: suppress strict-aliasing warning with
gcc version 4.4.0 20090219 (Red Hat 4.4.0-0.21) on Fedora 11 Alpha. * ext/socket/socket.c: ditto. * ext/socket/unixsocket.c: ditto. * ext/socket/sockport.h (SS_LEN): defined. (SET_SS_LEN): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d8c66c4333
commit
5fb1faf2bf
5 changed files with 31 additions and 10 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
Sat Feb 28 00:18:40 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/raddrinfo.c: suppress strict-aliasing warning with
|
||||
gcc version 4.4.0 20090219 (Red Hat 4.4.0-0.21) on Fedora 11 Alpha.
|
||||
|
||||
* ext/socket/socket.c: ditto.
|
||||
|
||||
* ext/socket/unixsocket.c: ditto.
|
||||
|
||||
* ext/socket/sockport.h (SS_LEN): defined.
|
||||
(SET_SS_LEN): ditto.
|
||||
|
||||
Fri Feb 27 22:30:18 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/ancdata.c (bsock_recvmsg_internal): close FDs passed by
|
||||
|
|
|
@ -1255,15 +1255,16 @@ addrinfo_mload(VALUE self, VALUE ary)
|
|||
#ifdef HAVE_SYS_UN_H
|
||||
case AF_UNIX:
|
||||
{
|
||||
struct sockaddr_un *su = (struct sockaddr_un *)&ss;
|
||||
memset(su, 0, sizeof(*su));
|
||||
su->sun_family = AF_UNIX;
|
||||
struct sockaddr_un sun;
|
||||
memset(&sun, 0, sizeof(sun));
|
||||
sun.sun_family = AF_UNIX;
|
||||
|
||||
StringValue(v);
|
||||
if (sizeof(su->sun_path) <= RSTRING_LEN(v))
|
||||
if (sizeof(sun.sun_path) <= RSTRING_LEN(v))
|
||||
rb_raise(rb_eSocket, "too long AF_UNIX path");
|
||||
memcpy(su->sun_path, RSTRING_PTR(v), RSTRING_LEN(v));
|
||||
len = sizeof(*su);
|
||||
memcpy(sun.sun_path, RSTRING_PTR(v), RSTRING_LEN(v));
|
||||
len = sizeof(sun);
|
||||
memcpy(&ss, &sun, len);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1157,7 +1157,7 @@ sock_s_getnameinfo(int argc, VALUE *argv)
|
|||
rb_raise(rb_eTypeError, "sockaddr length too big");
|
||||
}
|
||||
memcpy(&ss, RSTRING_PTR(sa), RSTRING_LEN(sa));
|
||||
if (RSTRING_LEN(sa) != SA_LEN((struct sockaddr*)&ss)) {
|
||||
if (RSTRING_LEN(sa) != SS_LEN(&ss)) {
|
||||
rb_raise(rb_eTypeError, "sockaddr size differs - should not happen");
|
||||
}
|
||||
sap = (struct sockaddr*)&ss;
|
||||
|
|
|
@ -13,22 +13,29 @@
|
|||
#ifndef SA_LEN
|
||||
# ifdef HAVE_SA_LEN
|
||||
# define SA_LEN(sa) (sa)->sa_len
|
||||
# define SS_LEN(ss) (ss)->ss_len
|
||||
# else
|
||||
# ifdef AF_INET6
|
||||
# define SA_LEN(sa) \
|
||||
(((sa)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \
|
||||
: sizeof(struct sockaddr))
|
||||
# define SS_LEN(ss) \
|
||||
(((ss)->ss_family == AF_INET6) ? sizeof(struct sockaddr_in6) \
|
||||
: sizeof(struct sockaddr))
|
||||
# else
|
||||
/* by tradition, sizeof(struct sockaddr) covers most of the sockaddrs */
|
||||
# define SA_LEN(sa) (sizeof(struct sockaddr))
|
||||
# define SS_LEN(ss) (sizeof(struct sockaddr))
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_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_SIN_LEN
|
||||
|
|
|
@ -236,7 +236,7 @@ unix_send_io(VALUE sock, VALUE val)
|
|||
cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(int));
|
||||
cmsg.hdr.cmsg_level = SOL_SOCKET;
|
||||
cmsg.hdr.cmsg_type = SCM_RIGHTS;
|
||||
*(int *)CMSG_DATA(&cmsg.hdr) = fd;
|
||||
memcpy(CMSG_DATA(&cmsg.hdr), &fd, sizeof(int));
|
||||
#else
|
||||
arg.msg.msg_accrights = (caddr_t)&fd;
|
||||
arg.msg.msg_accrightslen = sizeof(fd);
|
||||
|
@ -321,7 +321,8 @@ unix_recv_io(int argc, VALUE *argv, VALUE sock)
|
|||
cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(int));
|
||||
cmsg.hdr.cmsg_level = SOL_SOCKET;
|
||||
cmsg.hdr.cmsg_type = SCM_RIGHTS;
|
||||
*(int *)CMSG_DATA(&cmsg.hdr) = -1;
|
||||
fd = -1;
|
||||
memcpy(CMSG_DATA(&cmsg.hdr), &fd, sizeof(int));
|
||||
#else
|
||||
arg.msg.msg_accrights = (caddr_t)&fd;
|
||||
arg.msg.msg_accrightslen = sizeof(fd);
|
||||
|
@ -374,7 +375,7 @@ unix_recv_io(int argc, VALUE *argv, VALUE sock)
|
|||
#endif
|
||||
|
||||
#if FD_PASSING_BY_MSG_CONTROL
|
||||
fd = *(int *)CMSG_DATA(&cmsg.hdr);
|
||||
memcpy(&fd, CMSG_DATA(&cmsg.hdr), sizeof(int));
|
||||
#endif
|
||||
|
||||
if (klass == Qnil)
|
||||
|
|
Loading…
Add table
Reference in a new issue