diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2012-04-10 01:26:18 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-04-10 01:26:18 -0400 |
commit | 9e140917788c5853cd87850cd9b6b0b5474465f3 (patch) | |
tree | e407132cea87a0f1e5e4122b9955aed4951baeda /src/launcher-util.c | |
parent | 035dd9c4de5c14aed63a63c12ebe711bad09264a (diff) |
weston-launcher: Fix aliasing warnings
Diffstat (limited to 'src/launcher-util.c')
-rw-r--r-- | src/launcher-util.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/launcher-util.c b/src/launcher-util.c index acfcc3ee..519cd9df 100644 --- a/src/launcher-util.c +++ b/src/launcher-util.c @@ -37,16 +37,19 @@ #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; @@ -90,15 +93,15 @@ weston_launcher_open(struct weston_compositor *compositor, 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 @@ -112,6 +115,7 @@ weston_launcher_drm_set_master(struct weston_compositor *compositor, int ret; ssize_t len; struct weston_launcher_set_master message; + union cmsg_data *data; if (compositor->launcher_sock == -1) { if (master) @@ -130,7 +134,8 @@ weston_launcher_drm_set_master(struct weston_compositor *compositor, 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; |