From c4f3d5b38e4e1e88237f67380246c5f2fdeec7fd Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 23 Jun 2021 17:58:41 +0100 Subject: [PATCH] Add do-while protection to macros missed do-while around function-like macros (UINT32_BE and UINT_LE macros) originally present in the indivdual files, before being moved to common.h. Signed-off-by: Joe Subbiani --- library/common.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/library/common.h b/library/common.h index c2cf633c99..56514b3436 100644 --- a/library/common.h +++ b/library/common.h @@ -81,22 +81,22 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c */ #ifndef GET_UINT32_BE #define GET_UINT32_BE(n,b,i) \ -{ \ +do { \ (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ | ( (uint32_t) (b)[(i) + 1] << 16 ) \ | ( (uint32_t) (b)[(i) + 2] << 8 ) \ | ( (uint32_t) (b)[(i) + 3] ); \ -} +} while( 0 ) #endif #ifndef PUT_UINT32_BE #define PUT_UINT32_BE(n,b,i) \ -{ \ +do { \ (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ (b)[(i) + 3] = (unsigned char) ( (n) ); \ -} +} while( 0 ) #endif /* @@ -104,22 +104,22 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c */ #ifndef GET_UINT32_LE #define GET_UINT32_LE(n,b,i) \ -{ \ +do { \ (n) = ( (uint32_t) (b)[(i) ] ) \ | ( (uint32_t) (b)[(i) + 1] << 8 ) \ | ( (uint32_t) (b)[(i) + 2] << 16 ) \ | ( (uint32_t) (b)[(i) + 3] << 24 ); \ -} +} while( 0 ) #endif #ifndef PUT_UINT32_LE #define PUT_UINT32_LE(n,b,i) \ -{ \ +do { \ (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ -} +} while( 0 ) #endif /**