Skip to content

Commit 4439fae

Browse files
committed
format with astyle (step 3)
1 parent 9eed07f commit 4439fae

24 files changed

+689
-689
lines changed

bn_mp_init.c

+15-15
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@
1818
/* init a new mp_int */
1919
int mp_init(mp_int *a)
2020
{
21-
int i;
21+
int i;
2222

23-
/* allocate memory required and clear it */
24-
a->dp = OPT_CAST(mp_digit) XMALLOC(sizeof (mp_digit) * MP_PREC);
25-
if (a->dp == NULL) {
26-
return MP_MEM;
27-
}
23+
/* allocate memory required and clear it */
24+
a->dp = OPT_CAST(mp_digit) XMALLOC(sizeof(mp_digit) * MP_PREC);
25+
if (a->dp == NULL) {
26+
return MP_MEM;
27+
}
2828

29-
/* set the digits to zero */
30-
for (i = 0; i < MP_PREC; i++) {
29+
/* set the digits to zero */
30+
for (i = 0; i < MP_PREC; i++) {
3131
a->dp[i] = 0;
32-
}
32+
}
3333

34-
/* set the used to zero, allocated digits to the default precision
35-
* and sign to positive */
36-
a->used = 0;
37-
a->alloc = MP_PREC;
38-
a->sign = MP_ZPOS;
34+
/* set the used to zero, allocated digits to the default precision
35+
* and sign to positive */
36+
a->used = 0;
37+
a->alloc = MP_PREC;
38+
a->sign = MP_ZPOS;
3939

40-
return MP_OKAY;
40+
return MP_OKAY;
4141
}
4242
#endif
4343

bn_mp_init_copy.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
/* creates "a" then copies b into it */
1919
int mp_init_copy(mp_int *a, mp_int *b)
2020
{
21-
int res;
21+
int res;
2222

23-
if ((res = mp_init_size(a, b->used)) != MP_OKAY) {
24-
return res;
25-
}
23+
if ((res = mp_init_size(a, b->used)) != MP_OKAY) {
24+
return res;
25+
}
2626

27-
if ((res = mp_copy(b, a)) != MP_OKAY) {
28-
mp_clear(a);
29-
}
27+
if ((res = mp_copy(b, a)) != MP_OKAY) {
28+
mp_clear(a);
29+
}
3030

31-
return res;
31+
return res;
3232
}
3333
#endif
3434

bn_mp_init_multi.c

+27-27
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,35 @@
1818

1919
int mp_init_multi(mp_int *mp, ...)
2020
{
21-
mp_err res = MP_OKAY; /* Assume ok until proven otherwise */
22-
int n = 0; /* Number of ok inits */
23-
mp_int* cur_arg = mp;
24-
va_list args;
21+
mp_err res = MP_OKAY; /* Assume ok until proven otherwise */
22+
int n = 0; /* Number of ok inits */
23+
mp_int *cur_arg = mp;
24+
va_list args;
2525

26-
va_start(args, mp); /* init args to next argument from caller */
27-
while (cur_arg != NULL) {
28-
if (mp_init(cur_arg) != MP_OKAY) {
29-
/* Oops - error! Back-track and mp_clear what we already
30-
succeeded in init-ing, then return error.
31-
*/
32-
va_list clean_args;
26+
va_start(args, mp); /* init args to next argument from caller */
27+
while (cur_arg != NULL) {
28+
if (mp_init(cur_arg) != MP_OKAY) {
29+
/* Oops - error! Back-track and mp_clear what we already
30+
succeeded in init-ing, then return error.
31+
*/
32+
va_list clean_args;
3333

34-
/* now start cleaning up */
35-
cur_arg = mp;
36-
va_start(clean_args, mp);
37-
while (n-- != 0) {
38-
mp_clear(cur_arg);
39-
cur_arg = va_arg(clean_args, mp_int*);
40-
}
41-
va_end(clean_args);
42-
res = MP_MEM;
43-
break;
44-
}
45-
n++;
46-
cur_arg = va_arg(args, mp_int*);
47-
}
48-
va_end(args);
49-
return res; /* Assumed ok, if error flagged above. */
34+
/* now start cleaning up */
35+
cur_arg = mp;
36+
va_start(clean_args, mp);
37+
while (n-- != 0) {
38+
mp_clear(cur_arg);
39+
cur_arg = va_arg(clean_args, mp_int *);
40+
}
41+
va_end(clean_args);
42+
res = MP_MEM;
43+
break;
44+
}
45+
n++;
46+
cur_arg = va_arg(args, mp_int *);
47+
}
48+
va_end(args);
49+
return res; /* Assumed ok, if error flagged above. */
5050
}
5151

5252
#endif

bn_mp_init_set.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
/* initialize and set a digit */
1919
int mp_init_set(mp_int *a, mp_digit b)
2020
{
21-
int err;
22-
if ((err = mp_init(a)) != MP_OKAY) {
23-
return err;
24-
}
25-
mp_set(a, b);
26-
return err;
21+
int err;
22+
if ((err = mp_init(a)) != MP_OKAY) {
23+
return err;
24+
}
25+
mp_set(a, b);
26+
return err;
2727
}
2828
#endif
2929

bn_mp_init_set_int.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
/* initialize and set a digit */
1919
int mp_init_set_int(mp_int *a, unsigned long b)
2020
{
21-
int err;
22-
if ((err = mp_init(a)) != MP_OKAY) {
23-
return err;
24-
}
25-
return mp_set_int(a, b);
21+
int err;
22+
if ((err = mp_init(a)) != MP_OKAY) {
23+
return err;
24+
}
25+
return mp_set_int(a, b);
2626
}
2727
#endif
2828

bn_mp_init_size.c

+16-16
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,28 @@
1818
/* init an mp_init for a given size */
1919
int mp_init_size(mp_int *a, int size)
2020
{
21-
int x;
21+
int x;
2222

23-
/* pad size so there are always extra digits */
24-
size += (MP_PREC * 2) - (size % MP_PREC);
23+
/* pad size so there are always extra digits */
24+
size += (MP_PREC * 2) - (size % MP_PREC);
2525

26-
/* alloc mem */
27-
a->dp = OPT_CAST(mp_digit) XMALLOC(sizeof (mp_digit) * size);
28-
if (a->dp == NULL) {
29-
return MP_MEM;
30-
}
26+
/* alloc mem */
27+
a->dp = OPT_CAST(mp_digit) XMALLOC(sizeof(mp_digit) * size);
28+
if (a->dp == NULL) {
29+
return MP_MEM;
30+
}
3131

32-
/* set the members */
33-
a->used = 0;
34-
a->alloc = size;
35-
a->sign = MP_ZPOS;
32+
/* set the members */
33+
a->used = 0;
34+
a->alloc = size;
35+
a->sign = MP_ZPOS;
3636

37-
/* zero the digits */
38-
for (x = 0; x < size; x++) {
37+
/* zero the digits */
38+
for (x = 0; x < size; x++) {
3939
a->dp[x] = 0;
40-
}
40+
}
4141

42-
return MP_OKAY;
42+
return MP_OKAY;
4343
}
4444
#endif
4545

bn_mp_invmod.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@
1818
/* hac 14.61, pp608 */
1919
int mp_invmod(mp_int *a, mp_int *b, mp_int *c)
2020
{
21-
/* b cannot be negative */
22-
if ((b->sign == MP_NEG) || (mp_iszero(b) == MP_YES)) {
23-
return MP_VAL;
24-
}
21+
/* b cannot be negative */
22+
if ((b->sign == MP_NEG) || (mp_iszero(b) == MP_YES)) {
23+
return MP_VAL;
24+
}
2525

2626
#ifdef BN_FAST_MP_INVMOD_C
27-
/* if the modulus is odd we can use a faster routine instead */
28-
if ((mp_isodd(b) == MP_YES) && (mp_cmp_d(b, 1) != MP_EQ)) {
29-
return fast_mp_invmod(a, b, c);
30-
}
27+
/* if the modulus is odd we can use a faster routine instead */
28+
if ((mp_isodd(b) == MP_YES) && (mp_cmp_d(b, 1) != MP_EQ)) {
29+
return fast_mp_invmod(a, b, c);
30+
}
3131
#endif
3232

3333
#ifdef BN_MP_INVMOD_SLOW_C
34-
return mp_invmod_slow(a, b, c);
34+
return mp_invmod_slow(a, b, c);
3535
#else
36-
return MP_VAL;
36+
return MP_VAL;
3737
#endif
3838
}
3939
#endif

0 commit comments

Comments
 (0)