diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/acid/expr.c | 3 | ||||
-rw-r--r-- | src/cmd/db/format.c | 5 | ||||
-rw-r--r-- | src/cmd/vbackup/vnfs.c | 19 | ||||
-rw-r--r-- | src/lib9/_p9dialparse.c | 2 | ||||
-rw-r--r-- | src/lib9/sendfd.c | 2 | ||||
-rw-r--r-- | src/lib9/truerand.c | 4 | ||||
-rw-r--r-- | src/libauthsrv/readnvram.c | 6 | ||||
-rw-r--r-- | src/libavl/avl.c | 4 | ||||
-rw-r--r-- | src/libip/udp.c | 8 | ||||
-rw-r--r-- | src/libmach/Linux.c | 6 | ||||
-rw-r--r-- | src/libmemdraw/draw.c | 27 |
11 files changed, 57 insertions, 29 deletions
diff --git a/src/cmd/acid/expr.c b/src/cmd/acid/expr.c index 2330c430..61d5951e 100644 --- a/src/cmd/acid/expr.c +++ b/src/cmd/acid/expr.c @@ -855,11 +855,12 @@ ocand(Node *n, Node *res) { Node l, r; - res->store.fmt = l.store.fmt; + res->store.fmt = 'D'; res->op = OCONST; res->type = TINT; res->store.u.ival = 0; expr(n->left, &l); + res->store.fmt = l.store.fmt; if(bool(&l) == 0) return; expr(n->right, &r); diff --git a/src/cmd/db/format.c b/src/cmd/db/format.c index 08068e61..7a93bc5f 100644 --- a/src/cmd/db/format.c +++ b/src/cmd/db/format.c @@ -60,7 +60,7 @@ exform(int fcount, int prt, char *ifp, Map *map, int literal, int firstpass) char *fp; char c, modifier; int i; - ushort sh, *sp; + ushort sh; uchar ch, *cp; Symbol s; char buf[512]; @@ -205,7 +205,8 @@ exform(int fcount, int prt, char *ifp, Map *map, int literal, int firstpass) case 'R': if (literal) { - sp = (u16int*)(void*)˙ + u16int sp[2]; + memmove(&sp, &dot, 4); dprint("%C%C", sp[0], sp[1]); endline(); dotinc = 4; diff --git a/src/cmd/vbackup/vnfs.c b/src/cmd/vbackup/vnfs.c index cb9fdbf5..d4319c86 100644 --- a/src/cmd/vbackup/vnfs.c +++ b/src/cmd/vbackup/vnfs.c @@ -322,10 +322,14 @@ cryptinit(void) { uchar key[32], ivec[AESbsize]; int i; + u32int u32; - *(u32int*)sessid = truerand(); - for(i=0; i<nelem(key); i+=4) - *(u32int*)&key[i] = truerand(); + u32 = truerand(); + memmove(sessid, &u32, 4); + for(i=0; i<nelem(key); i+=4) { + u32 = truerand(); + memmove(key+i, &u32, 4); + } for(i=0; i<nelem(ivec); i++) ivec[i] = fastrand(); setupAESstate(&aesstate, key, sizeof key, ivec); @@ -793,6 +797,8 @@ cnodelookup(Ctree *t, Cnode **np, char *name) Nfs3Status cnodegetattr(Cnode *n, Nfs3Attr *attr) { + uint64 u64; + memset(attr, 0, sizeof *attr); if(n->read){ attr->type = Nfs3FileReg; @@ -805,7 +811,8 @@ cnodegetattr(Cnode *n, Nfs3Attr *attr) attr->size = 1024; attr->nlink = 10; } - attr->fileid = *(u64int*)n->handle; + memmove(&u64, n->handle, 8); + attr->fileid = u64; attr->atime.sec = n->mtime; attr->mtime.sec = n->mtime; attr->ctime.sec = n->mtime; @@ -817,6 +824,7 @@ cnodereaddir(Cnode *n, u32int count, u64int cookie, uchar **pdata, u32int *pcoun { uchar *data, *p, *ep, *np; u64int c; + u64int u64; Nfs3Entry ne; n = n->kidlist; @@ -842,7 +850,8 @@ cnodereaddir(Cnode *n, u32int count, u64int cookie, uchar **pdata, u32int *pcoun ne.name = n->name; ne.namelen = strlen(n->name); ne.cookie = ++cookie; - ne.fileid = *(u64int*)n->handle; + memmove(&u64, n->handle, 8); + ne.fileid = u64; if(nfs3entrypack(p, ep, &np, &ne) < 0) break; p = np; 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; } diff --git a/src/libauthsrv/readnvram.c b/src/libauthsrv/readnvram.c index 11e6950b..f65db984 100644 --- a/src/libauthsrv/readnvram.c +++ b/src/libauthsrv/readnvram.c @@ -76,8 +76,6 @@ readnvram(Nvrsafe *safep, int flag) if(strcmp(cputype, "386")==0 || strcmp(cputype, "alpha")==0) cputype = "pc"; - safe = (Nvrsafe*)buf; - fd = -1; safeoff = -1; safelen = -1; @@ -140,7 +138,7 @@ readnvram(Nvrsafe *safep, int flag) memset(safep, 0, sizeof(*safep)); safe = safep; }else{ - *safep = *safe; + memmove(safep, buf, sizeof *safep); safe = safep; err |= check(safe->machkey, DESKEYLEN, safe->machsum, "bad nvram key"); @@ -163,7 +161,7 @@ readnvram(Nvrsafe *safep, int flag) safe->configsum = nvcsum(safe->config, CONFIGLEN); safe->authidsum = nvcsum(safe->authid, sizeof(safe->authid)); safe->authdomsum = nvcsum(safe->authdom, sizeof(safe->authdom)); - *(Nvrsafe*)buf = *safe; + memmove(buf, safe, sizeof *safe); if(seek(fd, safeoff, 0) < 0 || write(fd, buf, safelen) != safelen){ fprint(2, "can't write key to nvram: %r\n"); diff --git a/src/libavl/avl.c b/src/libavl/avl.c index 2567c98d..b2c2f7d9 100644 --- a/src/libavl/avl.c +++ b/src/libavl/avl.c @@ -211,6 +211,7 @@ _deleteavl(Avl **tp, Avl *p, Avl *rx, int(*cmp)(Avl*,Avl*), Avl **del, return -(ob != 0 && (*tp)->bal == 0); } +/* static void checkparents(Avl *a, Avl *p) { @@ -221,6 +222,7 @@ checkparents(Avl *a, Avl *p) checkparents(a->n[0], a); checkparents(a->n[1], a); } +*/ struct Avltree { @@ -403,6 +405,7 @@ endwalk(Avlwalk *w) free(w); } +/* static void walkavl(Avl *t, void (*f)(Avl*, void*), void *v) { @@ -412,3 +415,4 @@ walkavl(Avl *t, void (*f)(Avl*, void*), void *v) f(t, v); walkavl(t->n[1], f, v); } +*/ diff --git a/src/libip/udp.c b/src/libip/udp.c index 042aa7e9..f318c4c3 100644 --- a/src/libip/udp.c +++ b/src/libip/udp.c @@ -21,8 +21,8 @@ udpread(int fd, Udphdr *hdr, void *buf, long n) } memset(hdr, 0, sizeof *hdr); memmove(hdr->laddr, v4prefix, IPaddrlen); - *(u32int*)(hdr->laddr+12) = *(u32int*)&sin.sin_addr; - *(u16int*)hdr->lport = *(u16int*)&sin.sin_port; + memmove(hdr->laddr+12, &sin.sin_addr, sizeof(u32int)); + memmove(hdr->lport, &sin.sin_port, sizeof(u16int)); len = sizeof sin; n = recvfrom(fd, buf, n, 0, (struct sockaddr*)&sin, &len); @@ -33,8 +33,8 @@ udpread(int fd, Udphdr *hdr, void *buf, long n) return -1; } memmove(hdr->raddr, v4prefix, IPaddrlen); - *(u32int*)(hdr->raddr+12) = *(u32int*)&sin.sin_addr; - *(u16int*)hdr->rport = *(u16int*)&sin.sin_port; + memmove(hdr->raddr+12, &sin.sin_addr, sizeof(u32int)); + memmove(hdr->rport, &sin.sin_port, sizeof(u16int)); return n; } diff --git a/src/libmach/Linux.c b/src/libmach/Linux.c index eb01a6e6..2a06f6a1 100644 --- a/src/libmach/Linux.c +++ b/src/libmach/Linux.c @@ -146,7 +146,7 @@ ptracerw(int type, int xtype, int isr, int pid, ulong addr, void *v, uint n) if(n-i >= 4) *(u32int*)((char*)v+i) = u; else{ - *(u32int*)buf = u; + memmove(buf, &u, 4); memmove((char*)v+i, buf, n-i); } }else{ @@ -157,9 +157,9 @@ ptracerw(int type, int xtype, int isr, int pid, ulong addr, void *v, uint n) u = ptrace(xtype, pid, addr+i, 0); if(errno) return -1; - *(u32int*)buf = u; + memmove(buf, &u, 4); memmove(buf, (char*)v+i, n-i); - u = *(u32int*)buf; + memmove(&u, buf, 4); } if(ptrace(type, pid, addr+i, u) < 0) goto ptraceerr; diff --git a/src/libmemdraw/draw.c b/src/libmemdraw/draw.c index 7616997b..4b988586 100644 --- a/src/libmemdraw/draw.c +++ b/src/libmemdraw/draw.c @@ -2109,6 +2109,7 @@ memoptdraw(Memdrawparam *par) { int m, y, dy, dx, op; u32int v; + u16int u16; Memimage *src; Memimage *dst; @@ -2198,7 +2199,8 @@ DBG print("dp %p v %lux lm %ux (v ^ *dp) & lm %lux\n", dp, v, lm, (v^*dp)&lm); case 16: p[0] = v; /* make little endian */ p[1] = v>>8; - v = *(ushort*)p; + memmove(&u16, p, 2); + v = u16; DBG print("dp=%p; dx=%d; for(y=0; y<%d; y++, dp+=%d)\nmemsets(dp, v, dx);\n", dp, dx, dy, dwid); for(y=0; y<dy; y++, dp+=dwid) @@ -2213,7 +2215,7 @@ DBG print("dp=%p; dx=%d; for(y=0; y<%d; y++, dp+=%d)\nmemsets(dp, v, dx);\n", p[1] = v>>8; p[2] = v>>16; p[3] = v>>24; - v = *(u32int*)p; + memmove(&v, p, 4); for(y=0; y<dy; y++, dp+=dwid) memsetl(dp, v, dx); return 1; @@ -2371,6 +2373,13 @@ chardraw(Memdrawparam *par) uchar sp[4]; Rectangle r, mr; Memimage *mask, *src, *dst; + union { + // black box to hide pointer conversions from gcc. + // we'll see how long this works. + uchar *u8; + u16int *u16; + u32int *u32; + } gcc_black_box; if(0) if(drawdebug) iprint("chardraw? mf %lux md %d sf %lux dxs %d dys %d dd %d ddat %p sdat %p\n", par->mask->flags, par->mask->depth, par->src->flags, @@ -2443,8 +2452,10 @@ DBG print("bits %lux sh %d...", bits, i); } break; case 16: - ws = (ushort*)wp; - v = *(ushort*)sp; + gcc_black_box.u8 = wp; + ws = gcc_black_box.u16; + gcc_black_box.u8 = sp; + v = *gcc_black_box.u16; for(x=bx; x>ex; x--, ws++){ i = x&7; if(i == 8-1) @@ -2469,8 +2480,10 @@ DBG print("bits %lux sh %d...", bits, i); } break; case 32: - wl = (u32int*)wp; - v = *(u32int*)sp; + gcc_black_box.u8 = wp; + wl = gcc_black_box.u32; + gcc_black_box.u8 = sp; + v = *gcc_black_box.u32; for(x=bx; x>ex; x--, wl++){ i = x&7; if(i == 8-1) @@ -2537,7 +2550,7 @@ _memfillcolor(Memimage *i, u32int val) p[1] = bits>>8; p[2] = bits>>16; p[3] = bits>>24; - bits = *(u32int*)p; + memmove(&bits, p, 4); memsetl(wordaddr(i, i->r.min), bits, i->width*Dy(i->r)); break; } |