1
0
mirror of https://github.com/golang/go synced 2024-11-13 18:10:24 -07:00

liblink, cmd/gc: resolve several shift warnings

Address several warnings generated by clang -fsanitize=undefined

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/43050043
This commit is contained in:
Dave Cheney 2013-12-19 10:34:33 +11:00
parent 8606b97690
commit 3f6dbfc44c
3 changed files with 4 additions and 4 deletions

View File

@ -98,7 +98,7 @@ bvget(Bvec *bv, int32 i)
if(i < 0 || i >= bv->n)
fatal("bvget: index %d is out of bounds with length %d\n", i, bv->n);
mask = 1 << (i % WORDBITS);
mask = 1U << (i % WORDBITS);
word = bv->b[i / WORDBITS] & mask;
return word ? 1 : 0;
}

View File

@ -371,7 +371,7 @@ wrint(Biobuf *b, int64 sval)
uint64 uv, v;
uchar buf[10], *p;
uv = (uint64)(sval<<1) ^ (uint64)(int64)(sval>>63);
uv = ((uint64)sval<<1) ^ (uint64)(int64)(sval>>63);
p = buf;
for(v = uv; v >= 0x80; v >>= 7)
@ -634,7 +634,7 @@ rdint(Biobuf *f)
break;
}
return (int64)(uv>>1) ^ ((int64)uv<<63>>63);
return (int64)(uv>>1) ^ ((int64)((uint64)uv<<63)>>63);
}
static char*

View File

@ -313,7 +313,7 @@ getvarint(uchar **pp)
v = 0;
p = *pp;
for(shift = 0;; shift += 7) {
v |= (*p & 0x7F) << shift;
v |= (uint32)(*p & 0x7F) << shift;
if(!(*p++ & 0x80))
break;
}