CWARN.NOEFFECT.UCMP.LT.MACROIneffective comparison of unsigned value in a macro is always falseThe CWARN.NOEFFECT.UCMP.LT.MACRO checker flags code in macros, in which there is a comparison of an unsigned value to zero that is always false. Vulnerability and riskIf 'a' is an unsigned value, the comparisons a < 0 and 0 > a are always false. These comparisons have no effect, so it's probable that design intent isn't being accomplished. Vulnerable code example1 #define RETURN_NEGATIVE(x) if (x < 0) return x 2 3 int foo(usigned int a) { 4 RETURN_NEGATIVE(a); 5 return 0; 6 } Klocwork flags line 4, in which the macro RETURN_NEGATIVE contains a condition that is always false. Related checkers |