remove a warning building a test

With my compile switches (which are mostly derived from RedHat spec
file) I'm getting this warning:

stream-test.c: In function 'sock_fd_read':
stream-test.c:66:43: warning: dereferencing type-punned pointer will
break strict-aliasing rules [-Wstrict-aliasing]
             *fd = *((int *) CMSG_DATA(cmsg));
                                           ^

memcpy could decrease performance but as this is a test it's not
an issue.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Frediano Ziglio 2016-05-15 17:12:16 +01:00
parent fb10f5bf52
commit fa0c32f120

View File

@ -63,7 +63,7 @@ sock_fd_read(int sock, void *buf, ssize_t bufsize, int *fd)
exit(1);
}
*fd = *((int *) CMSG_DATA(cmsg));
memcpy(fd, CMSG_DATA(cmsg), sizeof(*fd));
} else
*fd = -1;
} else {