diff options
author | Russ Cox <rsc@swtch.com> | 2010-03-10 14:50:33 -0800 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2010-03-10 14:50:33 -0800 |
commit | 0c9c620f39e56c42802504003fd05664aba670a4 (patch) | |
tree | ad14a1a51f3b6193d0603725d62a34fbc4647c49 /src/lib9 | |
parent | 2fe14f1315eb8d3235ea8f978e5bd9444f467c2b (diff) | |
download | plan9port-0c9c620f39e56c42802504003fd05664aba670a4.tar.gz plan9port-0c9c620f39e56c42802504003fd05664aba670a4.tar.bz2 plan9port-0c9c620f39e56c42802504003fd05664aba670a4.zip |
fix type-punned pointer warnings from gcc
R=rsc
http://codereview.appspot.com/396042
Diffstat (limited to 'src/lib9')
-rw-r--r-- | src/lib9/_p9dialparse.c | 2 | ||||
-rw-r--r-- | src/lib9/sendfd.c | 2 | ||||
-rw-r--r-- | src/lib9/truerand.c | 4 |
3 files changed, 5 insertions, 3 deletions
diff --git a/src/lib9/_p9dialparse.c b/src/lib9/_p9dialparse.c index b7f5385a..0c84ecdb 100644 --- a/src/lib9/_p9dialparse.c +++ b/src/lib9/_p9dialparse.c @@ -71,7 +71,7 @@ parseip(char *host, u32int *pip) return -1; break; } - *pip = *(u32int*)addr; + memmove(pip, addr, 4); return 0; } diff --git a/src/lib9/sendfd.c b/src/lib9/sendfd.c index 10966828..b5e332ca 100644 --- a/src/lib9/sendfd.c +++ b/src/lib9/sendfd.c @@ -46,7 +46,7 @@ sendfd(int s, int fd) cmsg->cmsg_len = CMSG_LEN(sizeof(int)); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; - *(int*)CMSG_DATA(cmsg) = fd; + memmove(CMSG_DATA(cmsg), &fd, sizeof(int)); if((n=sendmsg(s, &msg, 0)) != iov.iov_len) return -1; diff --git a/src/lib9/truerand.c b/src/lib9/truerand.c index 03f3dce1..45f739e1 100644 --- a/src/lib9/truerand.c +++ b/src/lib9/truerand.c @@ -6,6 +6,7 @@ truerand(void) { int i, n; uchar buf[sizeof(ulong)]; + ulong x; static int randfd = -1; static char *randfile; @@ -21,5 +22,6 @@ truerand(void) for(i=0; i<sizeof(buf); i += n) if((n = readn(randfd, buf+i, sizeof(buf)-i)) < 0) sysfatal("can't read %s: %r", randfile); - return *((ulong*)buf); + memmove(&x, buf, sizeof x); + return x; } |