From 26d02e132742ebc6bebe90abdc17575f2a16d635 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 30 Oct 2018 09:29:25 +0000 Subject: [PATCH] Add more missing parentheses around macro parameters --- library/md4.c | 20 ++++++++++---------- library/sha512.c | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/library/md4.c b/library/md4.c index 41c5d545f..828fd4299 100644 --- a/library/md4.c +++ b/library/md4.c @@ -145,9 +145,9 @@ int mbedtls_internal_md4_process( mbedtls_md4_context *ctx, D = ctx->state[3]; #define F(x, y, z) (((x) & (y)) | ((~(x)) & (z))) -#define P(a,b,c,d,x,s) \ - do \ - { \ +#define P(a,b,c,d,x,s) \ + do \ + { \ (a) += F((b),(c),(d)) + (x); \ (a) = S((a),(s)); \ } while( 0 ) @@ -177,8 +177,8 @@ int mbedtls_internal_md4_process( mbedtls_md4_context *ctx, #define P(a,b,c,d,x,s) \ do \ { \ - (a) += F(b,c,d) + (x) + 0x5A827999; \ - (a) = S(a,s); \ + (a) += F((b),(c),(d)) + (x) + 0x5A827999; \ + (a) = S((a),(s)); \ } while( 0 ) P( A, B, C, D, X[ 0], 3 ); @@ -202,11 +202,11 @@ int mbedtls_internal_md4_process( mbedtls_md4_context *ctx, #undef F #define F(x,y,z) ((x) ^ (y) ^ (z)) -#define P(a,b,c,d,x,s) \ - do \ - { \ - (a) += F(b,c,d) + (x) + 0x6ED9EBA1; \ - (a) = S(a,s); \ +#define P(a,b,c,d,x,s) \ + do \ + { \ + (a) += F((b),(c),(d)) + (x) + 0x6ED9EBA1; \ + (a) = S((a),(s)); \ } while( 0 ) P( A, B, C, D, X[ 0], 3 ); diff --git a/library/sha512.c b/library/sha512.c index efc4acb40..bdd20b284 100644 --- a/library/sha512.c +++ b/library/sha512.c @@ -225,7 +225,7 @@ int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx, SHA512_VALIDATE_RET( (const unsigned char *)data != NULL ); #define SHR(x,n) ((x) >> (n)) -#define ROTR(x,n) (SHR(x,n) | ((x) << (64 - (n)))) +#define ROTR(x,n) (SHR((x),(n)) | ((x) << (64 - (n)))) #define S0(x) (ROTR(x, 1) ^ ROTR(x, 8) ^ SHR(x, 7)) #define S1(x) (ROTR(x,19) ^ ROTR(x,61) ^ SHR(x, 6)) @@ -236,12 +236,12 @@ int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx, #define F0(x,y,z) (((x) & (y)) | ((z) & ((x) | (y)))) #define F1(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) -#define P(a,b,c,d,e,f,g,h,x,K) \ - do \ - { \ +#define P(a,b,c,d,e,f,g,h,x,K) \ + do \ + { \ temp1 = (h) + S3(e) + F1((e),(f),(g)) + (K) + (x); \ temp2 = S2(a) + F0((a),(b),(c)); \ - (d) += temp1; (h) = temp1 + temp2; \ + (d) += temp1; (h) = temp1 + temp2; \ } while( 0 ) for( i = 0; i < 16; i++ )