mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-24 00:06:32 +01: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:
parent
20d707dd3e
commit
d6028a1894
23 changed files with 325 additions and 252 deletions
|
|
@ -67,8 +67,15 @@
|
|||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#define CHECK(code) if( ( ret = code ) != 0 ){ return( ret ); }
|
||||
#define CHECK_RANGE(min, max, val) if( val < min || val > max ){ return( ret ); }
|
||||
#define CHECK(code) if( ( ret = ( code ) ) != 0 ){ return( ret ); }
|
||||
#define CHECK_RANGE(min, max, val) \
|
||||
do \
|
||||
{ \
|
||||
if( ( val ) < ( min ) || ( val ) > ( max ) ) \
|
||||
{ \
|
||||
return( ret ); \
|
||||
} \
|
||||
} while( 0 )
|
||||
|
||||
/*
|
||||
* CertificateSerialNumber ::= INTEGER
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue