Skip to content

Commit 4f2e8f4

Browse files
committed
Apply review suggestions
1 parent 7917e14 commit 4f2e8f4

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ first and then compare it with zero.</p>
1111
</overview>
1212

1313
<recommendation>
14-
<p>Use parentheses to make the intended operation order explicit. To assign first and compare the
14+
<p>Use parentheses to make the intended order of operations explicit. To assign first and compare the
1515
assigned value, parenthesize the assignment. To intentionally assign the comparison result,
1616
parenthesize the comparison. An explicit cast around the comparison also makes that order clear.</p>
1717
</recommendation>
1818

1919
<example>
2020
<p>In the first condition, <code>status</code> receives either zero or one instead of the value
21-
returned by <code>read_status</code>. The second condition explicitly performs the assignment
21+
returned by <code>read_status()</code>. The second condition explicitly performs the assignment
2222
before the comparison.</p>
2323
<sample src="AmbiguousAssignmentOfComparison.cpp" />
2424
</example>

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/**
2-
* @name Ambiguous assignment of comparison used as truth value
3-
* @description Assigning the result of an unparenthesized comparison when the assignment is used
4-
* as a truth value may indicate that the assignment and comparison are grouped
5-
* incorrectly.
2+
* @name Ambiguous assignment of comparison result used as truth value
3+
* @description Using an assignment of an unparenthesized comparison as
4+
* a truth value may indicate unintended operator grouping.
65
* @kind problem
76
* @problem.severity warning
87
* @precision high
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
category: newQuery
33
---
4-
* Added a new query, `cpp/ambiguous-assignment-of-comparison`, to detect assignments of
5-
unparenthesized comparison results when the assignment is used as a truth value.
4+
* Added a new query, `cpp/ambiguous-assignment-of-comparison`, to detect potentially
5+
ambiguous expressions where a comparison result is assigned to a variable and the
6+
assignment is used as a truth value.

0 commit comments

Comments
 (0)