aboutsummaryrefslogtreecommitdiff
path: root/session/direct-ipc.c
diff options
context:
space:
mode:
authorScott Anderson <ascent12@hotmail.com>2017-07-11 00:14:55 +1200
committerScott Anderson <ascent12@hotmail.com>2017-07-11 00:14:55 +1200
commit8189c64d7f07a756abf5a6189719f02b2f1af967 (patch)
tree26a5b75622d0a750478dee5c8a5d99f5b75846b6 /session/direct-ipc.c
parentbe064df25ee7c03543bb86d27addaa297682fba7 (diff)
Fixed that warnings that showed up with optimisations.
Diffstat (limited to 'session/direct-ipc.c')
-rw-r--r--session/direct-ipc.c10
1 files changed, 8 insertions, 2 deletions
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 <errno.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/socket.h>
@@ -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;