refactor without err initialization

This commit is contained in:
Francois Perrad 2019-05-19 15:32:46 +02:00
parent 8b2daf7817
commit fd68b6526c
3 changed files with 5 additions and 6 deletions

View File

@ -6,12 +6,12 @@
/* Decrement "a" by one like "a--". Changes input! */
mp_err mp_decr(mp_int *a)
{
mp_err err = MP_OKAY;
if (MP_IS_ZERO(a)) {
mp_set(a,1uL);
a->sign = MP_NEG;
return MP_OKAY;
} else if (a->sign == MP_NEG) {
mp_err err;
a->sign = MP_ZPOS;
if ((err = mp_incr(a)) != MP_OKAY) {
return err;

View File

@ -6,11 +6,11 @@
/* Increment "a" by one like "a++". Changes input! */
mp_err mp_incr(mp_int *a)
{
mp_err err = MP_OKAY;
if (MP_IS_ZERO(a)) {
mp_set(a,1uL);
return MP_OKAY;
} else if (a->sign == MP_NEG) {
mp_err err;
a->sign = MP_ZPOS;
if ((err = mp_decr(a)) != MP_OKAY) {
return err;

View File

@ -20,7 +20,7 @@
mp_err mp_kronecker(const mp_int *a, const mp_int *p, int *c)
{
mp_int a1, p1, r;
mp_err err = MP_OKAY;
mp_err err;
int v, k;
static const int table[8] = {0, 1, 0, -1, 0, -1, 0, 1};
@ -28,16 +28,15 @@ mp_err mp_kronecker(const mp_int *a, const mp_int *p, int *c)
if (MP_IS_ZERO(p)) {
if ((a->used == 1) && (a->dp[0] == 1u)) {
*c = 1;
return err;
} else {
*c = 0;
return err;
}
return MP_OKAY;
}
if (MP_IS_EVEN(a) && MP_IS_EVEN(p)) {
*c = 0;
return err;
return MP_OKAY;
}
if ((err = mp_init_copy(&a1, a)) != MP_OKAY) {