Skip to content

Commit 8a04840

Browse files
committed
C++: Improve qhelp for IncorrectNotOperatorUsage.ql, including mention of an alternative fix.
1 parent f4e4e23 commit 8a04840

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

cpp/ql/src/Likely Bugs/Likely Typos/IncorrectNotOperatorUsage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
void f_warning(int i)
44
{
5-
// The usage of the logical not operator in this case is unlikely to be correct
5+
// BAD: the usage of the logical not operator in this case is unlikely to be correct
66
// as the output is being used as an operator for a bit-wise and operation
77
if (i & !FLAGS)
88
{
@@ -12,7 +12,7 @@ void f_warning(int i)
1212

1313
void f_fixed(int i)
1414
{
15-
if (i & ~FLAGS) // Changing the logical not operator for the bit-wise not operator would fix this logic
15+
if (i & ~FLAGS) // GOOD: Changing the logical not operator for the bit-wise not operator would fix this logic
1616
{
1717
// code
1818
}

cpp/ql/src/Likely Bugs/Likely Typos/IncorrectNotOperatorUsage.qhelp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
<p>Carefully inspect the flagged expressions. Consider the intent in the code logic, and decide whether it is necessary to change the not operator.</p>
1717
</recommendation>
1818

19+
<p>Here is an example of this issue and how it can be fixed:</p>
1920
<example><sample src="IncorrectNotOperatorUsage.cpp" /></example>
21+
<p>In other cases, particularly when the expressions have <code>bool</code> type, the fix may instead be of the form <code>a &amp;&amp; !b</code></p>
2022

2123
<references>
2224
<li>

0 commit comments

Comments
 (0)