summaryrefslogtreecommitdiff
path: root/ext/socket/unixsocket.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-27 15:21:23 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-27 15:21:23 +0000
commit5fb1faf2bfc87597dbbf1a6686bab6b36482529d (patch)
tree05ecf4363780e14bd42b26d179cc1bd37ffbf46b /ext/socket/unixsocket.c
parentd8c66c433393cb0ff97fcbd32f6a4fdc4d8f8b79 (diff)
* 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
Diffstat (limited to 'ext/socket/unixsocket.c')
-rw-r--r--ext/socket/unixsocket.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/socket/unixsocket.c b/ext/socket/unixsocket.c
index 5f8b860..ae596d6 100644
--- a/ext/socket/unixsocket.c
+++ b/ext/socket/unixsocket.c
@@ -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)