remove side effect inside parameter of macro MAX
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
diff --git a/bn_mp_tc_and.c b/bn_mp_tc_and.c
index e9fe4c6..d1f1b91 100644
--- a/bn_mp_tc_and.c
+++ b/bn_mp_tc_and.c
@@ -16,12 +16,14 @@
/* two complement and */
int mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c)
{
- int res = MP_OKAY, bits;
+ int res = MP_OKAY, bits, abits, bbits;
int as = mp_isneg(a), bs = mp_isneg(b);
mp_int *mx = NULL, _mx, acpy, bcpy;
if ((as != MP_NO) || (bs != MP_NO)) {
- bits = MAX(mp_count_bits(a), mp_count_bits(b));
+ abits = mp_count_bits(a);
+ bbits = mp_count_bits(b);
+ bits = MAX(abits, bbits);
res = mp_init_set_int(&_mx, 1uL);
if (res != MP_OKAY) {
goto end;
diff --git a/bn_mp_tc_or.c b/bn_mp_tc_or.c
index 91b6b40..f177c39 100644
--- a/bn_mp_tc_or.c
+++ b/bn_mp_tc_or.c
@@ -16,12 +16,14 @@
/* two complement or */
int mp_tc_or(const mp_int *a, const mp_int *b, mp_int *c)
{
- int res = MP_OKAY, bits;
+ int res = MP_OKAY, bits, abits, bbits;
int as = mp_isneg(a), bs = mp_isneg(b);
mp_int *mx = NULL, _mx, acpy, bcpy;
if ((as != MP_NO) || (bs != MP_NO)) {
- bits = MAX(mp_count_bits(a), mp_count_bits(b));
+ abits = mp_count_bits(a);
+ bbits = mp_count_bits(b);
+ bits = MAX(abits, bbits);
res = mp_init_set_int(&_mx, 1uL);
if (res != MP_OKAY) {
goto end;
diff --git a/bn_mp_tc_xor.c b/bn_mp_tc_xor.c
index 50fb12d..a2c67a2 100644
--- a/bn_mp_tc_xor.c
+++ b/bn_mp_tc_xor.c
@@ -16,12 +16,14 @@
/* two complement xor */
int mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c)
{
- int res = MP_OKAY, bits;
+ int res = MP_OKAY, bits, abits, bbits;
int as = mp_isneg(a), bs = mp_isneg(b);
mp_int *mx = NULL, _mx, acpy, bcpy;
if ((as != MP_NO) || (bs != MP_NO)) {
- bits = MAX(mp_count_bits(a), mp_count_bits(b));
+ abits = mp_count_bits(a);
+ bbits = mp_count_bits(b);
+ bits = MAX(abits, bbits);
res = mp_init_set_int(&_mx, 1uL);
if (res != MP_OKAY) {
goto end;