Merge pull request #287 from fperrad/20190522_lint

some linting
This commit is contained in:
Steffen Jaeckel 2019-05-22 11:53:57 +02:00 committed by GitHub
commit 07c1898754
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 21 additions and 22 deletions

View File

@ -9,7 +9,7 @@ mp_err mp_and(const mp_int *a, const mp_int *b, mp_int *c)
int used = MP_MAX(a->used, b->used) + 1, i;
mp_err err;
mp_digit ac = 1, bc = 1, cc = 1;
mp_sign csign = (a->sign == MP_NEG && b->sign == MP_NEG) ? MP_NEG : MP_ZPOS;
mp_sign csign = ((a->sign == MP_NEG) && (b->sign == MP_NEG)) ? MP_NEG : MP_ZPOS;
if (c->alloc < used) {
if ((err = mp_grow(c, used)) != MP_OKAY) {
@ -22,20 +22,20 @@ mp_err mp_and(const mp_int *a, const mp_int *b, mp_int *c)
/* convert to two complement if negative */
if (a->sign == MP_NEG) {
ac += i >= a->used ? MP_MASK : ~a->dp[i] & MP_MASK;
ac += (i >= a->used) ? MP_MASK : (~a->dp[i] & MP_MASK);
x = ac & MP_MASK;
ac >>= MP_DIGIT_BIT;
} else {
x = i >= a->used ? 0 : a->dp[i];
x = (i >= a->used) ? 0uL : a->dp[i];
}
/* convert to two complement if negative */
if (b->sign == MP_NEG) {
bc += i >= b->used ? MP_MASK : ~b->dp[i] & MP_MASK;
bc += (i >= b->used) ? MP_MASK : (~b->dp[i] & MP_MASK);
y = bc & MP_MASK;
bc >>= MP_DIGIT_BIT;
} else {
y = i >= b->used ? 0 : b->dp[i];
y = (i >= b->used) ? 0uL : b->dp[i];
}
c->dp[i] = x & y;

View File

@ -19,9 +19,9 @@ int mp_count_bits(const mp_int *a)
/* take the last digit and count the bits in it */
q = a->dp[a->used - 1];
while (q > (mp_digit)0) {
while (q > 0u) {
++r;
q >>= (mp_digit)1;
q >>= 1u;
}
return r;
}

View File

@ -49,7 +49,7 @@ mp_err mp_fread(mp_int *a, int radix, FILE *stream)
}
} while ((ch = fgetc(stream)) != EOF);
if (!mp_iszero(a)) {
if (a->used != 0) {
a->sign = neg;
}

View File

@ -24,10 +24,10 @@ static mp_digit s_digit_ilogb(mp_digit base, mp_digit n)
mp_digit ret, high = 1uL, low = 0uL, mid;
if (n < base) {
return (mp_digit)0uL;
return 0uL;
}
if (n == base) {
return (mp_digit)1uL;
return 1uL;
}
bracket_high = (mp_word) base ;

View File

@ -9,7 +9,7 @@ mp_err mp_or(const mp_int *a, const mp_int *b, mp_int *c)
int used = MP_MAX(a->used, b->used) + 1, i;
mp_err err;
mp_digit ac = 1, bc = 1, cc = 1;
mp_sign csign = (a->sign == MP_NEG || b->sign == MP_NEG) ? MP_NEG : MP_ZPOS;
mp_sign csign = ((a->sign == MP_NEG) || (b->sign == MP_NEG)) ? MP_NEG : MP_ZPOS;
if (c->alloc < used) {
if ((err = mp_grow(c, used)) != MP_OKAY) {
@ -22,20 +22,20 @@ mp_err mp_or(const mp_int *a, const mp_int *b, mp_int *c)
/* convert to two complement if negative */
if (a->sign == MP_NEG) {
ac += i >= a->used ? MP_MASK : ~a->dp[i] & MP_MASK;
ac += (i >= a->used) ? MP_MASK : (~a->dp[i] & MP_MASK);
x = ac & MP_MASK;
ac >>= MP_DIGIT_BIT;
} else {
x = i >= a->used ? 0 : a->dp[i];
x = (i >= a->used) ? 0uL : a->dp[i];
}
/* convert to two complement if negative */
if (b->sign == MP_NEG) {
bc += i >= b->used ? MP_MASK : ~b->dp[i] & MP_MASK;
bc += (i >= b->used) ? MP_MASK : (~b->dp[i] & MP_MASK);
y = bc & MP_MASK;
bc >>= MP_DIGIT_BIT;
} else {
y = i >= b->used ? 0 : b->dp[i];
y = (i >= b->used) ? 0uL : b->dp[i];
}
c->dp[i] = x | y;

View File

@ -22,20 +22,20 @@ mp_err mp_xor(const mp_int *a, const mp_int *b, mp_int *c)
/* convert to two complement if negative */
if (a->sign == MP_NEG) {
ac += i >= a->used ? MP_MASK : ~a->dp[i] & MP_MASK;
ac += (i >= a->used) ? MP_MASK : (~a->dp[i] & MP_MASK);
x = ac & MP_MASK;
ac >>= MP_DIGIT_BIT;
} else {
x = i >= a->used ? 0 : a->dp[i];
x = (i >= a->used) ? 0uL : a->dp[i];
}
/* convert to two complement if negative */
if (b->sign == MP_NEG) {
bc += i >= b->used ? MP_MASK : ~b->dp[i] & MP_MASK;
bc += (i >= b->used) ? MP_MASK : (~b->dp[i] & MP_MASK);
y = bc & MP_MASK;
bc >>= MP_DIGIT_BIT;
} else {
y = i >= b->used ? 0 : b->dp[i];
y = (i >= b->used) ? 0uL : b->dp[i];
}
c->dp[i] = x ^ y;

View File

@ -63,7 +63,7 @@ mp_err s_mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
goto LTM_ERRa2;
}
for (; count < a->used; count++) {
a2.dp[count - 2 * B] = a->dp[count];
a2.dp[count - (2 * B)] = a->dp[count];
a2.used++;
}
@ -88,7 +88,7 @@ mp_err s_mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
goto LTM_ERRb2;
}
for (; count < b->used; count++) {
b2.dp[count - 2 * B] = b->dp[count];
b2.dp[count - (2 * B)] = b->dp[count];
b2.used++;
}

View File

@ -401,7 +401,6 @@
# define BN_MP_ZERO_C
# define BN_MP_MUL_D_C
# define BN_MP_ADD_D_C
# define BN_MP_ISZERO_C
#endif
#if defined(BN_MP_FWRITE_C)