aboutsummaryrefslogtreecommitdiffstats
path: root/ipc.c
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-10-27 02:43:57 -0300
committerdequis <dx@dxzone.com.ar>2015-10-30 07:31:09 -0300
commit129e2825aa6d5e1d34c58cec57a0db312ccc6b87 (patch)
tree941c97fe8dfe21f696d74d40190b083434febece /ipc.c
parent0edc2fb9f963a735cbd02d944bc3f5dd0f0768bf (diff)
ipc: Fix strict aliasing warnings
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
Diffstat (limited to 'ipc.c')
-rw-r--r--ipc.c4
1 files changed, 2 insertions, 2 deletions
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