Fix the proliferation of warnings... does this still work?

This commit is contained in:
Sean Burke
2004-04-05 12:58:45 +00:00
parent 76ced545ed
commit 1569dde338
+27 -27
View File
@@ -203,7 +203,7 @@ Bignum modpow(Bignum base, Bignum exp, Bignum mod)
{ {
BignumInt *a, *b, *n, *m; BignumInt *a, *b, *n, *m;
int mshift; int mshift;
int mlen, i, j; int i,j,mlen;
Bignum result; Bignum result;
/* Allocate m of size mlen, copy mod to m */ /* Allocate m of size mlen, copy mod to m */
@@ -228,7 +228,7 @@ Bignum modpow(Bignum base, Bignum exp, Bignum mod)
i = mlen - base[0]; i = mlen - base[0];
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
n[j] = 0; n[j] = 0;
for (j = 0; j < base[0]; j++) for (j = 0; j < (int)base[0]; j++)
n[i + j] = base[base[0] - j]; n[i + j] = base[base[0] - j];
/* Allocate a and b of size 2*mlen. Set a = 1 */ /* Allocate a and b of size 2*mlen. Set a = 1 */
@@ -241,7 +241,7 @@ Bignum modpow(Bignum base, Bignum exp, Bignum mod)
/* Skip leading zero bits of exp. */ /* Skip leading zero bits of exp. */
i = 0; i = 0;
j = BIGNUM_INT_BITS-1; j = BIGNUM_INT_BITS-1;
while (i < exp[0] && (exp[exp[0] - i] & (1 << j)) == 0) { while (i < (int)exp[0] && (exp[exp[0] - i] & (1 << j)) == 0) {
j--; j--;
if (j < 0) { if (j < 0) {
i++; i++;
@@ -250,7 +250,7 @@ Bignum modpow(Bignum base, Bignum exp, Bignum mod)
} }
/* Main computation */ /* Main computation */
while (i < exp[0]) { while (i < (int)exp[0]) {
while (j >= 0) { while (j >= 0) {
internal_mul(a + mlen, a + mlen, b, mlen); internal_mul(a + mlen, a + mlen, b, mlen);
internal_mod(b, mlen * 2, m, mlen, NULL, 0); internal_mod(b, mlen * 2, m, mlen, NULL, 0);
@@ -339,7 +339,7 @@ Bignum modmul(Bignum p, Bignum q, Bignum mod)
i = pqlen - p[0]; i = pqlen - p[0];
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
n[j] = 0; n[j] = 0;
for (j = 0; j < p[0]; j++) for (j = 0; j < (int)p[0]; j++)
n[i + j] = p[p[0] - j]; n[i + j] = p[p[0] - j];
/* Allocate o of size pqlen, copy q to o */ /* Allocate o of size pqlen, copy q to o */
@@ -347,7 +347,7 @@ Bignum modmul(Bignum p, Bignum q, Bignum mod)
i = pqlen - q[0]; i = pqlen - q[0];
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
o[j] = 0; o[j] = 0;
for (j = 0; j < q[0]; j++) for (j = 0; j < (int)q[0]; j++)
o[i + j] = q[q[0] - j]; o[i + j] = q[q[0] - j];
/* Allocate a of size 2*pqlen for result */ /* Allocate a of size 2*pqlen for result */
@@ -431,7 +431,7 @@ static void bigdivmod(Bignum p, Bignum mod, Bignum result, Bignum quotient)
n = new BignumInt[plen]; n = new BignumInt[plen];
for (j = 0; j < plen; j++) for (j = 0; j < plen; j++)
n[j] = 0; n[j] = 0;
for (j = 1; j <= p[0]; j++) for (j = 1; j <= (int)p[0]; j++)
n[plen - j] = p[j]; n[plen - j] = p[j];
/* Main computation */ /* Main computation */
@@ -449,7 +449,7 @@ static void bigdivmod(Bignum p, Bignum mod, Bignum result, Bignum quotient)
/* Copy result to buffer */ /* Copy result to buffer */
if (result) { if (result) {
for (i = 1; i <= result[0]; i++) { for (i = 1; i <= (int)result[0]; i++) {
int j = plen - i; int j = plen - i;
result[i] = j >= 0 ? n[j] : 0; result[i] = j >= 0 ? n[j] : 0;
} }
@@ -470,7 +470,7 @@ static void bigdivmod(Bignum p, Bignum mod, Bignum result, Bignum quotient)
void decbn(Bignum bn) void decbn(Bignum bn)
{ {
int i = 1; int i = 1;
while (i < bn[0] && bn[i] == 0) while (i < (int)bn[0] && bn[i] == 0)
bn[i++] = BIGNUM_INT_MASK; bn[i++] = BIGNUM_INT_MASK;
bn[i]--; bn[i]--;
} }
@@ -622,7 +622,7 @@ int ssh2_bignum_length(Bignum bn)
*/ */
unsigned char bignum_byte( const Bignum bn, int i ) unsigned char bignum_byte( const Bignum bn, int i )
{ {
if (i >= BIGNUM_INT_BYTES * bn[0]) if (i >= BIGNUM_INT_BYTES * (int)bn[0])
return 0; /* beyond the end */ return 0; /* beyond the end */
else else
return (bn[i / BIGNUM_INT_BYTES + 1] >> return (bn[i / BIGNUM_INT_BYTES + 1] >>
@@ -634,7 +634,7 @@ unsigned char bignum_byte( const Bignum bn, int i )
*/ */
int bignum_bit(Bignum bn, int i) int bignum_bit(Bignum bn, int i)
{ {
if (i >= BIGNUM_INT_BITS * bn[0]) if (i >= BIGNUM_INT_BITS * (int)bn[0])
return 0; /* beyond the end */ return 0; /* beyond the end */
else else
return (bn[i / BIGNUM_INT_BITS + 1] >> (i % BIGNUM_INT_BITS)) & 1; return (bn[i / BIGNUM_INT_BITS + 1] >> (i % BIGNUM_INT_BITS)) & 1;
@@ -645,7 +645,7 @@ int bignum_bit(Bignum bn, int i)
*/ */
void bignum_set_bit(Bignum bn, int bitnum, int value) void bignum_set_bit(Bignum bn, int bitnum, int value)
{ {
if (bitnum >= BIGNUM_INT_BITS * bn[0]) if (bitnum >= BIGNUM_INT_BITS * (int)bn[0])
abort(); /* beyond the end */ abort(); /* beyond the end */
else { else {
int v = bitnum / BIGNUM_INT_BITS + 1; int v = bitnum / BIGNUM_INT_BITS + 1;
@@ -712,9 +712,9 @@ Bignum bignum_rshift(Bignum a, int shift)
shiftbb = BIGNUM_INT_BITS - shiftb; shiftbb = BIGNUM_INT_BITS - shiftb;
ai1 = a[shiftw + 1]; ai1 = a[shiftw + 1];
for (i = 1; i <= ret[0]; i++) { for (i = 1; i <= (int)ret[0]; i++) {
ai = ai1; ai = ai1;
ai1 = (i + shiftw + 1 <= a[0] ? a[i + shiftw + 1] : 0); ai1 = (i + shiftw + 1 <= (int)a[0] ? a[i + shiftw + 1] : 0);
ret[i] = ((ai >> shiftb) | (ai1 << shiftbb)) & BIGNUM_INT_MASK; ret[i] = ((ai >> shiftb) | (ai1 << shiftbb)) & BIGNUM_INT_MASK;
} }
} }
@@ -736,8 +736,8 @@ Bignum bigmuladd(Bignum a, Bignum b, Bignum addend)
/* mlen space for a, mlen space for b, 2*mlen for result */ /* mlen space for a, mlen space for b, 2*mlen for result */
workspace = new BignumInt[mlen * 4]; workspace = new BignumInt[mlen * 4];
for (i = 0; i < mlen; i++) { for (i = 0; i < mlen; i++) {
workspace[0 * mlen + i] = (mlen - i <= a[0] ? a[mlen - i] : 0); workspace[0 * mlen + i] = (mlen - i <= (int)a[0] ? a[mlen - i] : 0);
workspace[1 * mlen + i] = (mlen - i <= b[0] ? b[mlen - i] : 0); workspace[1 * mlen + i] = (mlen - i <= (int)b[0] ? b[mlen - i] : 0);
} }
internal_mul(workspace + 0 * mlen, workspace + 1 * mlen, internal_mul(workspace + 0 * mlen, workspace + 1 * mlen,
@@ -745,11 +745,11 @@ Bignum bigmuladd(Bignum a, Bignum b, Bignum addend)
/* now just copy the result back */ /* now just copy the result back */
rlen = alen + blen + 1; rlen = alen + blen + 1;
if (addend && rlen <= addend[0]) if (addend && rlen <= (int)addend[0])
rlen = addend[0] + 1; rlen = addend[0] + 1;
ret = newbn(rlen); ret = newbn(rlen);
maxspot = 0; maxspot = 0;
for (i = 1; i <= ret[0]; i++) { for (i = 1; i <= (int)ret[0]; i++) {
ret[i] = (i <= 2 * mlen ? workspace[4 * mlen - i] : 0); ret[i] = (i <= 2 * mlen ? workspace[4 * mlen - i] : 0);
if (ret[i] != 0) if (ret[i] != 0)
maxspot = i; maxspot = i;
@@ -760,8 +760,8 @@ Bignum bigmuladd(Bignum a, Bignum b, Bignum addend)
if (addend) { if (addend) {
BignumDblInt carry = 0; BignumDblInt carry = 0;
for (i = 1; i <= rlen; i++) { for (i = 1; i <= rlen; i++) {
carry += (i <= ret[0] ? ret[i] : 0); carry += (i <= (int)ret[0] ? ret[i] : 0);
carry += (i <= addend[0] ? addend[i] : 0); carry += (i <= (int)addend[0] ? addend[i] : 0);
ret[i] = (BignumInt) carry & BIGNUM_INT_MASK; ret[i] = (BignumInt) carry & BIGNUM_INT_MASK;
carry >>= BIGNUM_INT_BITS; carry >>= BIGNUM_INT_BITS;
if (ret[i] != 0 && i > maxspot) if (ret[i] != 0 && i > maxspot)
@@ -832,9 +832,9 @@ Bignum bignum_add_long(Bignum number, unsigned long addendx)
int i, maxspot = 0; int i, maxspot = 0;
BignumDblInt carry = 0, addend = addendx; BignumDblInt carry = 0, addend = addendx;
for (i = 1; i <= ret[0]; i++) { for (i = 1; i <= (int)ret[0]; i++) {
carry += addend & BIGNUM_INT_MASK; carry += addend & BIGNUM_INT_MASK;
carry += (i <= number[0] ? number[i] : 0); carry += (i <= (int)number[0] ? number[i] : 0);
addend >>= BIGNUM_INT_BITS; addend >>= BIGNUM_INT_BITS;
ret[i] = (BignumInt) carry & BIGNUM_INT_MASK; ret[i] = (BignumInt) carry & BIGNUM_INT_MASK;
carry >>= BIGNUM_INT_BITS; carry >>= BIGNUM_INT_BITS;
@@ -943,9 +943,9 @@ Bignum modinv(Bignum number, Bignum modulus)
int maxspot = 1; int maxspot = 1;
int i; int i;
for (i = 1; i <= newx[0]; i++) { for (i = 1; i <= (int)newx[0]; i++) {
BignumInt aword = (i <= modulus[0] ? modulus[i] : 0); BignumInt aword = (i <= (int)modulus[0] ? modulus[i] : 0);
BignumInt bword = (i <= x[0] ? x[i] : 0); BignumInt bword = (i <= (int)x[0] ? x[i] : 0);
newx[i] = aword - bword - carry; newx[i] = aword - bword - carry;
bword = ~bword; bword = ~bword;
carry = carry ? (newx[i] >= bword) : (newx[i] > bword); carry = carry ? (newx[i] >= bword) : (newx[i] > bword);
@@ -997,7 +997,7 @@ char *bignum_decimal(Bignum x)
* big-endian form of the number. * big-endian form of the number.
*/ */
workspace = new BignumInt[x[0]]; workspace = new BignumInt[x[0]];
for (i = 0; i < x[0]; i++) for (i = 0; i < (int)x[0]; i++)
workspace[i] = x[x[0] - i]; workspace[i] = x[x[0] - i];
/* /*
@@ -1010,7 +1010,7 @@ char *bignum_decimal(Bignum x)
do { do {
iszero = 1; iszero = 1;
carry = 0; carry = 0;
for (i = 0; i < x[0]; i++) { for (i = 0; i < (int)x[0]; i++) {
carry = (carry << BIGNUM_INT_BITS) + workspace[i]; carry = (carry << BIGNUM_INT_BITS) + workspace[i];
workspace[i] = (BignumInt) (carry / 10); workspace[i] = (BignumInt) (carry / 10);
if (workspace[i]) if (workspace[i])