Merge pull request #747 from dgarske/integer_min_max

Fix naming for integer.c min/max local variables
pull/761/head
toddouska 2017-02-21 13:21:52 -08:00 committed by GitHub
commit f4f5d2d569
1 changed files with 19 additions and 19 deletions

View File

@ -1509,31 +1509,31 @@ int mp_add (mp_int * a, mp_int * b, mp_int * c)
int s_mp_add (mp_int * a, mp_int * b, mp_int * c) int s_mp_add (mp_int * a, mp_int * b, mp_int * c)
{ {
mp_int *x; mp_int *x;
int olduse, res, min, max; int olduse, res, min_ab, max_ab;
/* find sizes, we let |a| <= |b| which means we have to sort /* find sizes, we let |a| <= |b| which means we have to sort
* them. "x" will point to the input with the most digits * them. "x" will point to the input with the most digits
*/ */
if (a->used > b->used) { if (a->used > b->used) {
min = b->used; min_ab = b->used;
max = a->used; max_ab = a->used;
x = a; x = a;
} else { } else {
min = a->used; min_ab = a->used;
max = b->used; max_ab = b->used;
x = b; x = b;
} }
/* init result */ /* init result */
if (c->alloc < max + 1) { if (c->alloc < max_ab + 1) {
if ((res = mp_grow (c, max + 1)) != MP_OKAY) { if ((res = mp_grow (c, max_ab + 1)) != MP_OKAY) {
return res; return res;
} }
} }
/* get old used digit count and set new one */ /* get old used digit count and set new one */
olduse = c->used; olduse = c->used;
c->used = max + 1; c->used = max_ab + 1;
{ {
mp_digit u, *tmpa, *tmpb, *tmpc; mp_digit u, *tmpa, *tmpb, *tmpc;
@ -1552,7 +1552,7 @@ int s_mp_add (mp_int * a, mp_int * b, mp_int * c)
/* zero the carry */ /* zero the carry */
u = 0; u = 0;
for (i = 0; i < min; i++) { for (i = 0; i < min_ab; i++) {
/* Compute the sum at one digit, T[i] = A[i] + B[i] + U */ /* Compute the sum at one digit, T[i] = A[i] + B[i] + U */
*tmpc = *tmpa++ + *tmpb++ + u; *tmpc = *tmpa++ + *tmpb++ + u;
@ -1566,8 +1566,8 @@ int s_mp_add (mp_int * a, mp_int * b, mp_int * c)
/* now copy higher words if any, that is in A+B /* now copy higher words if any, that is in A+B
* if A or B has more digits add those in * if A or B has more digits add those in
*/ */
if (min != max) { if (min_ab != max_ab) {
for (; i < max; i++) { for (; i < max_ab; i++) {
/* T[i] = X[i] + U */ /* T[i] = X[i] + U */
*tmpc = x->dp[i] + u; *tmpc = x->dp[i] + u;
@ -1596,20 +1596,20 @@ int s_mp_add (mp_int * a, mp_int * b, mp_int * c)
/* low level subtraction (assumes |a| > |b|), HAC pp.595 Algorithm 14.9 */ /* low level subtraction (assumes |a| > |b|), HAC pp.595 Algorithm 14.9 */
int s_mp_sub (mp_int * a, mp_int * b, mp_int * c) int s_mp_sub (mp_int * a, mp_int * b, mp_int * c)
{ {
int olduse, res, min, max; int olduse, res, min_b, max_a;
/* find sizes */ /* find sizes */
min = b->used; min_b = b->used;
max = a->used; max_a = a->used;
/* init result */ /* init result */
if (c->alloc < max) { if (c->alloc < max_a) {
if ((res = mp_grow (c, max)) != MP_OKAY) { if ((res = mp_grow (c, max_a)) != MP_OKAY) {
return res; return res;
} }
} }
olduse = c->used; olduse = c->used;
c->used = max; c->used = max_a;
{ {
mp_digit u, *tmpa, *tmpb, *tmpc; mp_digit u, *tmpa, *tmpb, *tmpc;
@ -1622,7 +1622,7 @@ int s_mp_sub (mp_int * a, mp_int * b, mp_int * c)
/* set carry to zero */ /* set carry to zero */
u = 0; u = 0;
for (i = 0; i < min; i++) { for (i = 0; i < min_b; i++) {
/* T[i] = A[i] - B[i] - U */ /* T[i] = A[i] - B[i] - U */
*tmpc = *tmpa++ - *tmpb++ - u; *tmpc = *tmpa++ - *tmpb++ - u;
@ -1638,7 +1638,7 @@ int s_mp_sub (mp_int * a, mp_int * b, mp_int * c)
} }
/* now copy higher words if any, e.g. if A has more digits than B */ /* now copy higher words if any, e.g. if A has more digits than B */
for (; i < max; i++) { for (; i < max_a; i++) {
/* T[i] = A[i] - U */ /* T[i] = A[i] - U */
*tmpc = *tmpa++ - u; *tmpc = *tmpa++ - u;