MISRA.FUNC.UNUSEDRET.2012The value returned by a function having non-void return type shall be used.
MISRA C 2012 Rule 17.7: The return value of a non-void function shall be usedCategory: Required Analysis: Decidable, Single Translation Unit Applies to: C90, C99 RationaleIt is possible to call a function without using the return value, which may be an error. If the return value of a function is intended not to be used explicitly, it should be cast to the void type. This has the effect of using the value without violating Rule 2.2. Exampleuint16_t func ( uin t16_t para1 ) { return para1; } uint16_t x; void discarded ( uint16_t para2 ) { func ( para2 ); /* Non-compliant - value discarded */ ( void ) func ( para2 ); /* Compliant */ x = func ( para2 ); /* Compliant */ } See alsoDir 4.7, Rule 2.2 |