Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4ba5b7b

Browse filesBrowse files
committed
minor improvements
1 parent 785f29b commit 4ba5b7b
Copy full SHA for 4ba5b7b

File tree

Expand file treeCollapse file tree

1 file changed

+12
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-3
lines changed

‎c/cert/src/rules/ERR32-C/DoNotRelyOnIndeterminateValuesOfErrno.ql

Copy file name to clipboardExpand all lines: c/cert/src/rules/ERR32-C/DoNotRelyOnIndeterminateValuesOfErrno.ql
+12-3Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,20 @@ import codingstandards.c.cert
1515
import codingstandards.c.Errno
1616
import semmle.code.cpp.controlflow.Guards
1717

18+
/**
19+
* A call to function `signal`
20+
*/
1821
class SignalCall extends FunctionCall {
1922
SignalCall() { this.getTarget().hasGlobalName("signal") }
2023
}
2124

25+
/**
26+
* A call to `abort` or `_Exit`
27+
*/
28+
class AbortCall extends FunctionCall {
29+
AbortCall() { this.getTarget().hasGlobalName(["abort", "_Exit"]) }
30+
}
31+
2232
/**
2333
* A check on `signal` call return value
2434
* `if (signal(SIGINT, handler) == SIG_ERR)`
@@ -59,9 +69,8 @@ class SignalCallingHandler extends Function {
5969
DataFlow::localFlow(DataFlow::parameterNode(this.getParameter(0)),
6070
DataFlow::exprNode(sCall.getArgument(0))) and
6171
// does not abort on error
62-
not exists(SignalCheckOperation sCheck, FunctionCall abort |
72+
not exists(SignalCheckOperation sCheck, AbortCall abort |
6373
DataFlow::localExprFlow(sCall, sCheck.getAnOperand()) and
64-
abort.getTarget().hasGlobalName(["abort", "_Exit"]) and
6574
abort.getEnclosingElement*() = sCheck.getErrorSuccessor()
6675
)
6776
)
@@ -80,7 +89,7 @@ ControlFlowNode preceedErrnoRead(ErrnoRead er) {
8089
result = mid.getAPredecessor() and
8190
mid = preceedErrnoRead(er) and
8291
// stop recursion on calls to `abort` and `_Exit`
83-
not result.(FunctionCall).getTarget().hasGlobalName(["abort", "_Exit"]) and
92+
not result instanceof AbortCall and
8493
// stop recursion on successful `SignalCheckOperation`
8594
not result = any(SignalCheckOperation o).getCheckedSuccessor()
8695
)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.