remove side effect inside parameter of macro MAX

This commit is contained in:
Francois Perrad 2018-12-27 08:50:34 +01:00
parent b722832b32
commit 4fec1ae6f2
3 changed files with 12 additions and 6 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;