From 129e2825aa6d5e1d34c58cec57a0db312ccc6b87 Mon Sep 17 00:00:00 2001 From: dequis Date: Tue, 27 Oct 2015 02:43:57 -0300 Subject: ipc: Fix strict aliasing warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Turned out to be as simple as just using memcpy. As with all strict aliasing warnings, these only appeared when compiling with optimization, and might have caused Bad Thingsā„¢ This page is cool: http://dbp-consulting.com/tutorials/StrictAliasing.html --- ipc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ipc.c') diff --git a/ipc.c b/ipc.c index 4041f442..304a8ef2 100644 --- a/ipc.c +++ b/ipc.c @@ -589,7 +589,7 @@ static char *ipc_readline(int fd, int *recv_fd) close(*recv_fd); } - *recv_fd = *(int *) CMSG_DATA(cmsg); + memcpy(recv_fd, CMSG_DATA(cmsg), sizeof(int)); /* fprintf( stderr, "pid %d received fd %d\n", (int) getpid(), *recv_fd ); */ @@ -757,7 +757,7 @@ static gboolean ipc_send_fd(int fd, int send_fd) cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; cmsg->cmsg_len = CMSG_LEN(sizeof(send_fd)); - *(int *) CMSG_DATA(cmsg) = send_fd; + memcpy(CMSG_DATA(cmsg), &send_fd, sizeof(int)); msg.msg_controllen = cmsg->cmsg_len; #endif -- cgit v1.2.3