mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-02 09:01:38 -05:00
Fixed that warnings that showed up with optimisations.
This commit is contained in:
parent
be064df25e
commit
8189c64d7f
5 changed files with 15 additions and 11 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue