1- <!DOCTYPE qhelp PUBLIC
2- "-//Semmle//qhelp//EN"
3- "qhelp.dtd">
4- <qhelp >
5- <overview >
6- <p >The code compares the unsigned difference with zero.
7- It is highly probable that the condition is wrong if the difference expression has the unsigned type.
8- The condition holds in all the cases when difference is not equal to zero.
9- It means that we may use condition not equal. But the programmer probably wanted to compare the difference of elements.</p >
10-
11- <p >False positives include code in which the first difference element is always greater than or equal to the second.
12- For comparison, ">" such conditions are equivalent to "! =", And are recommended for replacement.
13- For comparison "> =", the conditions are always true and are recommended to be excluded.</p >
14-
15- </overview >
16- <recommendation >
17-
18- <p >Use a simple comparison of two elements, instead of comparing their difference to zero.</p >
19-
20- </recommendation >
21- <example >
22- <p >The following example demonstrates an erroneous and corrected use of comparison.</p >
23- <sample src =" UnsignedDifferenceExpressionComparedZero.c" />
24-
25- </example >
26- <references >
27-
28- <li >CERT C Coding Standard:
29- <a href =" https://wiki.sei.cmu.edu/confluence/display/c/INT02-C.+Understand+integer+conversion+rules" >INT02-C. Understand integer conversion rules</a >.
30- </li >
31-
32- </references >
33- </qhelp >
1+ <!DOCTYPE qhelp PUBLIC
2+ "-//Semmle//qhelp//EN"
3+ "qhelp.dtd">
4+ <qhelp >
5+ <overview >
6+ <p >The code compares the unsigned difference with zero.
7+ It is highly probable that the condition is wrong if the difference expression has the unsigned type.
8+ The condition holds in all the cases when difference is not equal to zero.
9+ It means that we may use condition not equal. But the programmer probably wanted to compare the difference of elements.</p >
10+
11+ <p >False positives include code in which the first difference element is always greater than or equal to the second.
12+ For comparison, ">" such conditions are equivalent to "! =", And are recommended for replacement.
13+ For comparison "> =", the conditions are always true and are recommended to be excluded.</p >
14+
15+ </overview >
16+ <recommendation >
17+
18+ <p >Use a simple comparison of two elements, instead of comparing their difference to zero.</p >
19+
20+ </recommendation >
21+ <example >
22+ <p >The following example demonstrates an erroneous and corrected use of comparison.</p >
23+ <sample src =" UnsignedDifferenceExpressionComparedZero.c" />
24+
25+ </example >
26+ <references >
27+
28+ <li >CERT C Coding Standard:
29+ <a href =" https://wiki.sei.cmu.edu/confluence/display/c/INT02-C.+Understand+integer+conversion+rules" >INT02-C. Understand integer conversion rules</a >.
30+ </li >
31+
32+ </references >
33+ </qhelp >
0 commit comments