Commit 3f6dbfc4 authored by Dave Cheney's avatar Dave Cheney

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
parent 8606b976
...@@ -98,7 +98,7 @@ bvget(Bvec *bv, int32 i) ...@@ -98,7 +98,7 @@ bvget(Bvec *bv, int32 i)
if(i < 0 || i >= bv->n) if(i < 0 || i >= bv->n)
fatal("bvget: index %d is out of bounds with length %d\n", 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; word = bv->b[i / WORDBITS] & mask;
return word ? 1 : 0; return word ? 1 : 0;
} }
......
...@@ -371,7 +371,7 @@ wrint(Biobuf *b, int64 sval) ...@@ -371,7 +371,7 @@ wrint(Biobuf *b, int64 sval)
uint64 uv, v; uint64 uv, v;
uchar buf[10], *p; uchar buf[10], *p;
uv = (uint64)(sval<<1) ^ (uint64)(int64)(sval>>63); uv = ((uint64)sval<<1) ^ (uint64)(int64)(sval>>63);
p = buf; p = buf;
for(v = uv; v >= 0x80; v >>= 7) for(v = uv; v >= 0x80; v >>= 7)
...@@ -634,7 +634,7 @@ rdint(Biobuf *f) ...@@ -634,7 +634,7 @@ rdint(Biobuf *f)
break; break;
} }
return (int64)(uv>>1) ^ ((int64)uv<<63>>63); return (int64)(uv>>1) ^ ((int64)((uint64)uv<<63)>>63);
} }
static char* static char*
......
...@@ -313,7 +313,7 @@ getvarint(uchar **pp) ...@@ -313,7 +313,7 @@ getvarint(uchar **pp)
v = 0; v = 0;
p = *pp; p = *pp;
for(shift = 0;; shift += 7) { for(shift = 0;; shift += 7) {
v |= (*p & 0x7F) << shift; v |= (uint32)(*p & 0x7F) << shift;
if(!(*p++ & 0x80)) if(!(*p++ & 0x80))
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment