ref: 64785f014f9260768224d218899905d1ec19d269
parent: 5b0abd4ef6ae0deca52d0d498d73a51d11387b38
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Nov 10 17:53:50 EST 2024
fix 1<<... style UBs
--- a/3rd/mp/mptod.c
+++ b/3rd/mp/mptod.c
@@ -20,7 +20,7 @@
r = 0;
if(n > 54){
s = n - 54;
- r = v & (1<<s) - 1;
+ r = v & (1ULL<<s) - 1;
v >>= s;
}
while(n < 54){
@@ -32,7 +32,7 @@
if(m > Dbits) m = Dbits;
s = Dbits - m & Dbits - 1;
v = v << m | w >> s;
- r = w & (1<<s) - 1;
+ r = w & (1ULL<<s) - 1;
n += m;
}
if((v & 3) == 1){
@@ -49,7 +49,7 @@
return a->sign < 0 ? D_NINF : D_PINF;
}
x.lo = v;
- x.hi = (u32int)(v >> 32) & (1<<20) - 1 | (sf + 1022) << 20 | a->sign & 1<<31;
+ x.hi = (u32int)(v >> 32) & (1<<20) - 1 | (sf + 1022) << 20 | a->sign & 1U<<31;
return x.x;
}
--- a/bitvector.c
+++ b/bitvector.c
@@ -62,13 +62,13 @@
bitvector_set(uint32_t *b, uint64_t n, uint32_t c)
{
if(c)
- b[n>>5] |= 1<<(n&31);
+ b[n>>5] |= 1U<<(n&31);
else
- b[n>>5] &= ~(1<<(n&31));
+ b[n>>5] &= ~(1U<<(n&31));
}
uint32_t
bitvector_get(uint32_t *b, uint64_t n)
{
- return b[n>>5] & (1<<(n&31));
+ return b[n>>5] & (1U<<(n&31));
}