MISRA.ZERO_EQ.IMPLICITNon-boolean expression is implicitly tested against zero. MISRA-C Rule 13.2 (advisory): Tests of a value against zero should be made explicit, unless the operand is effectively Boolean.Where a data value is to be tested against zero then the test should be made explicit. The exception to this rule is when data represents a Boolean value, even though in C this will in practice be an integer. This rule is in the interests of clarity, and makes clear the distinction between integers and logical values. ExampleFor example, if x is an integer, then: if ( x != 0 ) /* Correct way of testing x is non-zero */ if ( y ) /* Not compliant, unless y is effectively Boolean data (e.g. a flag) */ See "Boolean Expressions" in the glossary. |