...
The Coverity Prevent NEGATIVE_RETURNS and REVERSE_NEGATIVE checkers can both find violations of this rule. The NEGATIVE_RETURNS checker can find array accesses, loop bounds, and other expressions which may contain dangerous implied integer conversions that would result in unexpected behavior. The REVERSE_NEGATIVE checker can find instances where a negativity check occurs after the negative value has been used for something else. Coverity Prevent cannot discover all violations of this rule so further verification is necessary.
References
Wiki Markup |
---|
\[[Dowd 06|AA. C References#Dowd 06]\] Chapter 6, "C Language Issues" (Type Conversions, pp. 223-270) \[[ISO/IEC 9899-1999|AA. C References#ISO/IEC 9899-1999]\] 6.3, "Conversions" \[[SeacordMITRE 0507|AA. C References#SeacordReferences#MITRE 0507]\] [CWE Chapter 5ID 192|http://cwe.mitre.org/data/definitions/192.html], "IntegersInteger Coercion Error" \[[WarrenSeacord 0205|AA. C References#WarrenReferences#Seacord 0205]\] Chapter 25, "BasicsIntegers" \[[Viega 05|AA. C References#Viega 05]\] Section 5.2.9, "Truncation error," Section 5.2.10, "Sign extension error," Section 5.2.11, "Signed to unsigned conversion error," and Section 5.2.12, "Unsigned to signed conversion error" \[[DowdWarren 0602|AA. C References#DowdReferences#Warren 0602]\] Chapter 62, "C Language Issues" (Type Conversions, pp. 223-270)Basics" |