forked from github/codeql-coding-standards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMutexInitializedInsideThread.ql
More file actions
26 lines (24 loc) · 940 Bytes
/
MutexInitializedInsideThread.ql
File metadata and controls
26 lines (24 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
* @id c/misra/mutex-initialized-inside-thread
* @name RULE-22-14: Thread synchronization objects shall be initialized deterministically
* @description Mutex and condition objects initialized inside of threads may result in
* indeterministic state.
* @kind problem
* @precision high
* @problem.severity recommendation
* @tags external/misra/id/rule-22-14
* readability
* maintainability
* concurrency
* external/misra/c/2012/amendment4
* external/misra/obligation/mandatory
*/
import cpp
import codingstandards.c.misra
import codingstandards.cpp.ConcurrencyNew
from C11MutexSource mutexCreate, ThreadedFunction thread
where
not isExcluded(mutexCreate, Concurrency8Package::mutexInitializedInsideThreadQuery()) and
thread.calls*(mutexCreate.getEnclosingFunction())
select mutexCreate, "Mutex initialization reachable from threaded function '$@'.", thread,
thread.getName()