Skip to content

Commit 72d7223

Browse files
committed
C++: Small drive by cleanup. Delete unnecessary nested 'exists'.
1 parent d097946 commit 72d7223

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

cpp/ql/src/Critical/ScanfChecks.qll

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,18 @@ private string getEofValue() {
3232
* Holds if the value of `call` has been checked to not equal `EOF`.
3333
*/
3434
private predicate checkedForEof(ScanfFunctionCall call) {
35-
exists(IRGuardCondition gc |
36-
exists(CallInstruction i | i.getUnconvertedResultExpression() = call |
37-
exists(int val | gc.comparesEq(valueNumber(i).getAUse(), val, _, _) |
38-
// call == EOF
39-
val = getEofValue().toInt()
40-
or
41-
// call == [any positive number]
42-
val > 0
43-
)
35+
exists(IRGuardCondition gc, CallInstruction i | i.getUnconvertedResultExpression() = call |
36+
exists(int val | gc.comparesEq(valueNumber(i).getAUse(), val, _, _) |
37+
// call == EOF
38+
val = getEofValue().toInt()
4439
or
45-
exists(int val | gc.comparesLt(valueNumber(i).getAUse(), val, true, _) |
46-
// call < [any non-negative number] (EOF is guaranteed to be negative)
47-
val >= 0
48-
)
40+
// call == [any positive number]
41+
val > 0
42+
)
43+
or
44+
exists(int val | gc.comparesLt(valueNumber(i).getAUse(), val, true, _) |
45+
// call < [any non-negative number] (EOF is guaranteed to be negative)
46+
val >= 0
4947
)
5048
)
5149
}

0 commit comments

Comments
 (0)