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
library

View file

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