#include #include typedef _Bool bool_t; bool_t ishigh; uint16_t a, x; /* ----------------- Example code from MISRA C:2012 begin ----------------- */ int16_t f ( uint16_t y ) { uint16_t temp = y; temp = y + 0x8080U; return temp; } uint16_t h ( uint16_t y ) { static uint16_t temp = 0; temp = y + temp; return temp; } void g ( void ) { if ( ishigh && ( a == f ( x ) ) ) /* Compliant */ { } if ( ishigh && ( a == h ( x ) ) ) /* Non-compliant */ { } } volatile uint16_t v; uint16_t x; /* ------------------ Example code from MISRA C:2012 end ------------------ */ void example ( void ) { uint16_t ( *fp ) ( uint16_t para ) = h; /* ----------------- Example code from MISRA C:2012 begin ----------------- */ if ( ( x == 0u ) || ( v == 1u ) ) /* Non-compliant */ { } ( fp != NULL ) && ( *fp ) ( 0 ); /* Non-compliant */ /* ------------------ Example code from MISRA C:2012 end ------------------ */ }