...
Code that does not conform to the common practices presented is difficult to maintain. Bugs can easily arise when modifying helper functions that evaluate true/false or success/failure. Bugs can also easily arise when modifying code that tests for equality using a comparison function that obeys the same conventions as standard library functions such as strcmp
.
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
EXP20-C | Medium | Probable | Low | P12 | L1 |
Automated Detection
Tool | Version | Checker | Description | ||||
Astrée |
|
Supported indirectly via MISRA C:2004 Rule 13.2. | |||||||||
Axivion Bauhaus Suite |
| CertC-EXP20 | Fully implemented | ||||||
Helix QAC |
| C3344, C4116 | |||||||
LDRA tool suite |
| 114 S | Partially implemented | ||||||
Parasoft C/C++test |
3344
4116
| CERT_C-EXP20-a | Avoid comparing values with TRUE macro/enum constant using equality operators ("==", "!=") | |||||||
PC-lint Plus |
| 697 | Partially supported: reports comparisons of Boolean values to constants other than 0 |
Bibliography
[StackOvflw 2009] | "Should I Return TRUE/FALSE Values from a C Function?" |
...
...