Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix: fix aliasing warnings in stream.c
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Aug 23, 2012
1 parent b81e67a commit e89cb90
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/unix/stream.c
Expand Up @@ -655,7 +655,13 @@ static void uv__write(uv_stream_t* stream) {
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = msg.msg_controllen;
*(int*) CMSG_DATA(cmsg) = fd_to_send;

/* silence aliasing warning */
{
void* pv = CMSG_DATA(cmsg);
int* pi = pv;
*pi = fd_to_send;
}

do {
n = sendmsg(stream->fd, &msg, 0);
Expand Down Expand Up @@ -909,7 +915,12 @@ static void uv__read(uv_stream_t* stream) {
fprintf(stderr, "(libuv) ignoring extra FD received\n");
}

stream->accepted_fd = *(int *) CMSG_DATA(cmsg);
/* silence aliasing warning */
{
void* pv = CMSG_DATA(cmsg);
int* pi = pv;
stream->accepted_fd = *pi;
}

} else {
fprintf(stderr, "ignoring non-SCM_RIGHTS ancillary data: %d\n",
Expand Down

0 comments on commit e89cb90

Please sign in to comment.