Why is this an issue?
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.
Noncompliant code example
if ( x ) // Noncompliant, unless x is effectively Boolean data
Compliant solution
if ( x == 0) // Compliant solution
Resources
- MISRA C:2004, 13.2 - Tests of a value against zero should be made explicit, unless the operand is effectively Boolean.