fix type-punned pointer warnings from gcc

R=rsc
http://codereview.appspot.com/396042
This commit is contained in:
Russ Cox 2010-03-10 14:50:33 -08:00
parent 2fe14f1315
commit 0c9c620f39
11 changed files with 57 additions and 29 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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;