C defines <
, >
, <=
, and >=
to be relational operators, and it defines ==
and !=
to be equality operators.
If a for
or while
statement uses a loop counter, than it is safer to use a relational operator (such as <
) to terminate the loop than to use an equality operator (such as !=
).
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
...
...
...
...
. Use numerical comparison operators to terminate loops whose counter changes by more than one |
MISRA-C |
Sources
ISO/IEC 9899:2011 Section 6.5.8, "Relational operators," and Section 6.5.9, "Equality operators"
...