kconsumerd: fix strict aliasing
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 26 Sep 2011 18:59:49 +0000 (14:59 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 26 Sep 2011 18:59:49 +0000 (14:59 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttngkconsumerd/lttngkconsumerd.c

index 2e53f9a2dc00b5a123641e0a2314ec0418c78c87..1893e0ae66a2f110150b7e6aa219d32771c0b0c6 100644 (file)
@@ -245,12 +245,16 @@ static int kconsumerd_consumerd_recv_fd(
                enum lttng_kconsumerd_command cmd_type)
 {
        struct iovec iov[1];
-       int ret = 0, i, tmp2;
+       int ret = 0, i, j, tmp2;
        struct cmsghdr *cmsg;
        int nb_fd;
        char recv_fd[CMSG_SPACE(sizeof(int))];
        struct lttcomm_kconsumerd_msg lkm;
        struct lttng_kconsumerd_fd *new_fd;
+       union {
+               unsigned char vc[4];
+               int vi;
+       } tmp;
 
        /* the number of fds we are about to receive */
        nb_fd = size / sizeof(struct lttcomm_kconsumerd_msg);
@@ -298,10 +302,10 @@ static int kconsumerd_consumerd_recv_fd(
                if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) {
                        switch (cmd_type) {
                                case ADD_STREAM:
-                                       DBG("kconsumerd_add_fd %s (%d)", lkm.path_name,
-                                                       ((int *) CMSG_DATA(cmsg))[0]);
-
-                                       new_fd = kconsumerd_allocate_fd(&lkm, ((int *) CMSG_DATA(cmsg))[0]);
+                                       for (j = 0; j < sizeof(int); j++)
+                                               tmp.vc[j] = CMSG_DATA(cmsg)[j];
+                                       DBG("kconsumerd_add_fd %s (%d)", lkm.path_name, tmp.vi);
+                                       new_fd = kconsumerd_allocate_fd(&lkm, tmp.vi);
                                        if (new_fd == NULL) {
                                                lttng_kconsumerd_send_error(ctx, KCONSUMERD_OUTFD_ERROR);
                                                goto end;
This page took 0.04148 seconds and 4 git commands to generate.