#include "launcher-util.h"
#include "weston-launch.h"
+union cmsg_data { unsigned char b[4]; int fd; };
+
int
weston_launcher_open(struct weston_compositor *compositor,
const char *path, int flags)
{
int sock = compositor->launcher_sock;
- int fd, n, ret = -1;
+ int n, ret = -1;
struct msghdr msg;
struct cmsghdr *cmsg;
struct iovec iov;
- char control[CMSG_SPACE(sizeof fd)];
+ union cmsg_data *data;
+ char control[CMSG_SPACE(sizeof data->fd)];
ssize_t len;
struct weston_launcher_open *message;
goto out;
}
- fd = *(int *) CMSG_DATA(cmsg);
- if (fd == -1) {
+ data = (union cmsg_data *) CMSG_DATA(cmsg);
+ if (data->fd == -1) {
fprintf(stderr, "missing drm fd in socket request");
return -1;
}
out:
free(message);
- return ret < 0 ? ret : fd;
+ return ret < 0 ? ret : data->fd;
}
int
int ret;
ssize_t len;
struct weston_launcher_set_master message;
+ union cmsg_data *data;
if (compositor->launcher_sock == -1) {
if (master)
cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = CMSG_LEN(sizeof(drm_fd));
- *(int *) CMSG_DATA(cmsg) = drm_fd;
+ data = (union cmsg_data *) CMSG_DATA(cmsg);
+ data->fd = drm_fd;
msg.msg_controllen = cmsg->cmsg_len;
iov.iov_base = &message;
int verbose;
};
+union cmsg_data { unsigned char b[4]; int fd; };
+
static gid_t *
read_groups(void)
{
static int
handle_setmaster(struct weston_launch *wl, struct msghdr *msg, ssize_t len)
{
- int drm_fd = -1, ret = -1;
+ int ret = -1;
struct cmsghdr *cmsg;
struct weston_launcher_set_master *message;
+ union cmsg_data *data;
if (len != sizeof(*message)) {
error(0, 0, "missing value in setmaster request");
goto out;
}
- drm_fd = *(int *) CMSG_DATA(cmsg);
- if (drm_fd == -1) {
+ data = (union cmsg_data *) CMSG_DATA(cmsg);
+ if (data->fd == -1) {
error(0, 0, "missing drm fd in socket request");
goto out;
}
if (message->set_master)
- ret = drmSetMaster(drm_fd);
+ ret = drmSetMaster(data->fd);
else
- ret = drmDropMaster(drm_fd);
+ ret = drmDropMaster(data->fd);
- close(drm_fd);
+ close(data->fd);
out:
do {
len = send(wl->sock[0], &ret, sizeof ret, 0);
struct msghdr nmsg;
struct iovec iov;
struct weston_launcher_open *message;
+ union cmsg_data *data;
message = msg->msg_iov->iov_base;
if ((size_t)len < sizeof(*message))
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
- *(int *) CMSG_DATA(cmsg) = fd;
+ data = (union cmsg_data *) CMSG_DATA(cmsg);
+ data->fd = fd;
nmsg.msg_controllen = cmsg->cmsg_len;
ret = 0;
}