1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-01 10:06:53 +03:00

Improve macro hygiene

This commit improves hygiene and formatting of macro definitions
throughout the library. Specifically:
- It adds brackets around parameters to avoid unintended
  interpretation of arguments, e.g. due to operator precedence.
- It adds uses of the `do { ... } while( 0 )` idiom for macros that
  can be used as commands.
This commit is contained in:
Hanno Becker
2018-10-15 12:01:35 +01:00
committed by Simon Butcher
parent 9c99dc862c
commit 1eeca41472
23 changed files with 325 additions and 252 deletions

View File

@ -1444,7 +1444,7 @@ static int x509_info_subject_alt_name( char **buf, size_t *size,
}
#define CERT_TYPE(type,name) \
if( ns_cert_type & type ) \
if( ns_cert_type & (type) ) \
PRINT_ITEM( name );
static int x509_info_cert_type( char **buf, size_t *size,
@ -1471,7 +1471,7 @@ static int x509_info_cert_type( char **buf, size_t *size,
}
#define KEY_USAGE(code,name) \
if( key_usage & code ) \
if( key_usage & (code) ) \
PRINT_ITEM( name );
static int x509_info_key_usage( char **buf, size_t *size,