ref: e51fc2d4b90d29fedc7794c90d37d1ce862dcc74
parent: 4ee3d8da899b4d15b6d9f537804e06c754b9fcc5
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Jan 6 15:52:28 EST 2023
libmp: avoid parentesis warnings from gcc
--- a/libmp/cnfield.c
+++ b/libmp/cnfield.c
@@ -86,7 +86,7 @@
return nil;
f = nil;
d = N->p[N->top-1];
- for(s = 0; (d & (mpdigit)1<<Dbits-1) == 0; s++)
+ for(s = 0; (d & (mpdigit)1<<(Dbits-1)) == 0; s++)
d <<= 1;
C = mpnew(0);
M = mpcopy(N);
--- a/libmp/mpcmp.c
+++ b/libmp/mpcmp.c
@@ -26,5 +26,5 @@
int sign;
sign = (b1->sign - b2->sign) >> 1; // -1, 0, 1
- return sign | (sign&1)-1 & mpmagcmp(b1, b2)*b1->sign;
+ return sign | (((sign&1)-1) & mpmagcmp(b1, b2)*b1->sign);
}
--- a/libmp/mpdiv.c
+++ b/libmp/mpdiv.c
@@ -21,10 +21,10 @@
abort();
// division by one or small powers of two
- if(divisor->top == 1 && (divisor->p[0] & divisor->p[0]-1) == 0){
+ if(divisor->top == 1 && (divisor->p[0] & (divisor->p[0]-1)) == 0){
vlong r = 0;
if(dividend->top > 0)
- r = (vlong)dividend->sign * (dividend->p[0] & divisor->p[0]-1);
+ r = (vlong)dividend->sign * (dividend->p[0] & (divisor->p[0]-1));
if(quotient != nil){
sign = divisor->sign;
for(s = 0; ((divisor->p[0] >> s) & 1) == 0; s++)
--- a/libmp/mpfmt.c
+++ b/libmp/mpfmt.c
@@ -33,7 +33,7 @@
for(p = &b->p[b->top-1]; p >= b->p; p--){
x = *p;
for(i = Dbits-s; i >= 0; i -= s){
- j = x >> i & sn - 1;
+ j = (x >> i) & (sn - 1);
if(j != 0 || out != buf){
if(out >= eout)
return -1;
@@ -130,7 +130,7 @@
else if(x != 0)
return -1;
*out = '0' + (x & 7);
- x = y >> Dbits-i;
+ x = y >> (Dbits-i);
}
}
if(i > 0)
--- a/libmp/mplogic.c
+++ b/libmp/mplogic.c
@@ -34,7 +34,7 @@
t = b1;
b1 = b2;
b2 = t;
- fl = fl >> 2 & 0x03 | fl << 2 & 0x0c | fl & 0x30;
+ fl = ((fl >> 2) & 0x03) | ((fl << 2) & 0x0c) | (fl & 0x30);
}
mpbits(sum, b1->top*Dbits+1);
dp1 = b1->p;
@@ -165,7 +165,7 @@
for(i = 0; i < d; i++)
r->p[i] = b->p[i];
if(m != 0)
- r->p[d] = b->p[d] & (1<<m)-1;
+ r->p[d] = b->p[d] & ((1<<m)-1);
}
r->sign = 1;
mpnorm(r);
--- a/libmp/mpsel.c
+++ b/libmp/mpsel.c
@@ -21,7 +21,7 @@
mpbits(res, Dbits*(n >= m ? n : m));
res->top = n >= m ? n : m;
- s = (-s^s|s)>>(sizeof(s)*8-1);
+ s = ((-s^s)|s)>>(sizeof(s)*8-1);
res->sign = (b1->sign & s) | (b2->sign & ~s);
d = -((mpdigit)s & 1);
--- a/libmp/mpvectscmp.c
+++ b/libmp/mpvectscmp.c
@@ -12,12 +12,12 @@
v = 0;
while(alen > blen)
v |= a[--alen];
- m = p = (-v^v|v)>>Dbits-1;
+ m = p = ((-v^v)|v)>>(Dbits-1);
} else if(blen > alen){
v = 0;
while(blen > alen)
v |= b[--blen];
- m = (-v^v|v)>>Dbits-1;
+ m = ((-v^v)|v)>>(Dbits-1);
p = m^1;
} else
m = p = 0;
@@ -26,8 +26,8 @@
y = b[alen];
z = x - y;
x = ~x;
- v = ((-z^z|z)>>Dbits-1) & ~m;
- p = ((~(x&y|x&z|y&z)>>Dbits-1) & v) | (p & ~v);
+ v = (((-z^z)|z)>>(Dbits-1)) & ~m;
+ p = ((~((x&y)|(x&z)|(y&z))>>(Dbits-1)) & v) | (p & ~v);
m |= v;
}
return (p-m) | m;
--- a/libmp/strtomp.c
+++ b/libmp/strtomp.c
@@ -53,7 +53,7 @@
Digout:
i -= Dbits;
b->p[b->top++] = x;
- x = y >> 3-i;
+ x = y >> (3-i);
}
}
if(i > 0)