From 8189c64d7f07a756abf5a6189719f02b2f1af967 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Tue, 11 Jul 2017 00:14:55 +1200 Subject: Fixed that warnings that showed up with optimisations. --- session/direct-ipc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'session') diff --git a/session/direct-ipc.c b/session/direct-ipc.c index fbbde02a..885662e0 100644 --- a/session/direct-ipc.c +++ b/session/direct-ipc.c @@ -1,6 +1,8 @@ #define _POSIX_C_SOURCE 200809L #include #include +#include +#include #include #include #include @@ -62,7 +64,7 @@ static void send_msg(int sock, int fd, void *buf, size_t buf_len) { .cmsg_type = SCM_RIGHTS, .cmsg_len = CMSG_LEN(sizeof(fd)), }; - *(int *)CMSG_DATA(cmsg) = fd; + memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd)); } ssize_t ret; @@ -93,7 +95,11 @@ static ssize_t recv_msg(int sock, int *fd_out, void *buf, size_t buf_len) { if (fd_out) { struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msghdr); - *fd_out = cmsg ? *(int *)CMSG_DATA(cmsg) : -1; + if (cmsg) { + memcpy(fd_out, CMSG_DATA(cmsg), sizeof(*fd_out)); + } else { + *fd_out = -1; + } } return ret; -- cgit v1.2.3