From 4fec1ae6f2a61d8c0003e053d883b602bf159ca4 Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Thu, 27 Dec 2018 08:50:34 +0100 Subject: [PATCH] remove side effect inside parameter of macro MAX --- bn_mp_tc_and.c | 6 ++++-- bn_mp_tc_or.c | 6 ++++-- bn_mp_tc_xor.c | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) 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;