more type-punned pointers

R=rsc
http://codereview.appspot.com/376045
This commit is contained in:
Russ Cox 2010-03-10 14:59:03 -08:00
parent 0c9c620f39
commit 96898a8141
2 changed files with 3 additions and 3 deletions

View file

@ -83,6 +83,6 @@ recvfd(int s)
return -1;
}
cmsg = CMSG_FIRSTHDR(&msg);
fd = *(int*)CMSG_DATA(cmsg);
memmove(&fd, CMSG_DATA(cmsg), sizeof(int));
return fd;
}

View file

@ -46,8 +46,8 @@ udpwrite(int fd, Udphdr *hdr, void *buf, long n)
memset(&sin, 0, sizeof sin);
sin.sin_family = AF_INET;
*(u32int*)&sin.sin_addr = *(u32int*)(hdr->raddr+12);
*(u16int*)&sin.sin_port = *(u16int*)hdr->rport;
memmove(&sin.sin_addr, hdr->raddr+12, 4);
memmove(&sin.sin_port, hdr->rport, 2);
return sendto(fd, buf, n, 0, (struct sockaddr*)&sin, sizeof sin);
}