MISRA.INCR_DECR.OTHERIncrement or decrement operator is mixed with other operators in expression. MISRA-C Rule 12.13 (advisory): The increment (++) and decrement (--) operators should not be mixed with other operators in an expression.It is the intention of the rule that when the increment or decrement operator is used, it should be the only side effect in the statement. The use of increment and decrement operators in combination with other arithmetic operators is not recommended because:
It is safer to use these operations in isolation from any other arithmetic operators. For example a statement such as the following is not compliant: u8a = ++u8b + u8c--; /* Not compliant */ The following sequence is clearer and therefore safer: ++u8b; u8a = u8b + u8c; u8c--; MISRA-C++ Rule 5-2-10 (advisory): The increment (++) and decrement (--) operators should not be mixed with other operators in an expression.RationaleThe use of increment and decrement operators in combination with other arithmetic operators is not recommended, because:
It is safer to use these operators in isolation from any other arithmetic operators. ExampleA statement such as the following is non-compliant: u8a = ++u8b + u8c--; // Non-compliant The following sequence is clearer and therefore safer: ++u8b; u8a = u8b + u8c; u8c--; |