Skip to content

Commit 5ad2588

Browse files
fix test
1 parent 763f4c1 commit 5ad2588

File tree

3 files changed

+36
-34
lines changed

3 files changed

+36
-34
lines changed

c/misra/src/rules/DIR-5-3/ThreadCreatedByThread.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ class CThreadRoot extends Function {
2727
/* Get a function which is reachable from this function */
2828
Function getAReachableFunction() { calls*(result) }
2929

30-
CThreadCreateCall getCThreadCreateCall() { result = threadCreate }
30+
CThreadCreateCall getACThreadCreateCall() { result = threadCreate }
3131
}
3232

3333
from CThreadCreateCall tc, CThreadRoot threadRoot
3434
where
3535
not isExcluded(tc, Concurrency6Package::threadCreatedByThreadQuery()) and
3636
tc.getEnclosingFunction() = threadRoot.getAReachableFunction()
3737
select tc, "Thread creation call reachable from function '$@', which may also be $@.", threadRoot,
38-
threadRoot.toString(), threadRoot.getCThreadCreateCall(), "started as a thread"
38+
threadRoot.toString(), threadRoot.getACThreadCreateCall(), "started as a thread"
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
| test.c:47:3:47:13 | call to thrd_create | Thread creation call reachable from threaded function '$@'. | test.c:46:7:46:18 | pthread_func | pthread_func |
2-
| test.c:48:3:48:16 | call to pthread_create | Thread creation call reachable from threaded function '$@'. | test.c:46:7:46:18 | pthread_func | pthread_func |
3-
| test.c:56:3:56:13 | call to thrd_create | Thread creation call reachable from threaded function '$@'. | test.c:55:5:55:13 | thrd_func | thrd_func |
4-
| test.c:57:3:57:16 | call to pthread_create | Thread creation call reachable from threaded function '$@'. | test.c:55:5:55:13 | thrd_func | thrd_func |
5-
| test.c:65:3:65:13 | call to thrd_create | Thread creation call reachable from threaded function '$@'. | test.c:55:5:55:13 | thrd_func | thrd_func |
6-
| test.c:66:3:66:16 | call to pthread_create | Thread creation call reachable from threaded function '$@'. | test.c:55:5:55:13 | thrd_func | thrd_func |
7-
| test.c:74:3:74:13 | call to thrd_create | Thread creation call reachable from threaded function '$@'. | test.c:46:7:46:18 | pthread_func | pthread_func |
8-
| test.c:74:3:74:13 | call to thrd_create | Thread creation call reachable from threaded function '$@'. | test.c:55:5:55:13 | thrd_func | thrd_func |
9-
| test.c:75:3:75:16 | call to pthread_create | Thread creation call reachable from threaded function '$@'. | test.c:46:7:46:18 | pthread_func | pthread_func |
10-
| test.c:75:3:75:16 | call to pthread_create | Thread creation call reachable from threaded function '$@'. | test.c:55:5:55:13 | thrd_func | thrd_func |
11-
| test.c:79:3:79:13 | call to thrd_create | Thread creation call reachable from threaded function '$@'. | test.c:46:7:46:18 | pthread_func | pthread_func |
12-
| test.c:79:3:79:13 | call to thrd_create | Thread creation call reachable from threaded function '$@'. | test.c:55:5:55:13 | thrd_func | thrd_func |
13-
| test.c:80:3:80:16 | call to pthread_create | Thread creation call reachable from threaded function '$@'. | test.c:46:7:46:18 | pthread_func | pthread_func |
14-
| test.c:80:3:80:16 | call to pthread_create | Thread creation call reachable from threaded function '$@'. | test.c:55:5:55:13 | thrd_func | thrd_func |
1+
| test.c:49:3:49:13 | call to thrd_create | Thread creation call reachable from function '$@', which may also be $@. | test.c:48:7:48:18 | pthread_func | pthread_func | test.c:19:3:19:16 | call to pthread_create | started as a thread |
2+
| test.c:50:3:50:16 | call to pthread_create | Thread creation call reachable from function '$@', which may also be $@. | test.c:48:7:48:18 | pthread_func | pthread_func | test.c:19:3:19:16 | call to pthread_create | started as a thread |
3+
| test.c:58:3:58:13 | call to thrd_create | Thread creation call reachable from function '$@', which may also be $@. | test.c:57:5:57:13 | thrd_func | thrd_func | test.c:18:3:18:13 | call to thrd_create | started as a thread |
4+
| test.c:59:3:59:16 | call to pthread_create | Thread creation call reachable from function '$@', which may also be $@. | test.c:57:5:57:13 | thrd_func | thrd_func | test.c:18:3:18:13 | call to thrd_create | started as a thread |
5+
| test.c:67:3:67:13 | call to thrd_create | Thread creation call reachable from function '$@', which may also be $@. | test.c:57:5:57:13 | thrd_func | thrd_func | test.c:18:3:18:13 | call to thrd_create | started as a thread |
6+
| test.c:68:3:68:16 | call to pthread_create | Thread creation call reachable from function '$@', which may also be $@. | test.c:57:5:57:13 | thrd_func | thrd_func | test.c:18:3:18:13 | call to thrd_create | started as a thread |
7+
| test.c:76:3:76:13 | call to thrd_create | Thread creation call reachable from function '$@', which may also be $@. | test.c:48:7:48:18 | pthread_func | pthread_func | test.c:19:3:19:16 | call to pthread_create | started as a thread |
8+
| test.c:76:3:76:13 | call to thrd_create | Thread creation call reachable from function '$@', which may also be $@. | test.c:57:5:57:13 | thrd_func | thrd_func | test.c:18:3:18:13 | call to thrd_create | started as a thread |
9+
| test.c:77:3:77:16 | call to pthread_create | Thread creation call reachable from function '$@', which may also be $@. | test.c:48:7:48:18 | pthread_func | pthread_func | test.c:19:3:19:16 | call to pthread_create | started as a thread |
10+
| test.c:77:3:77:16 | call to pthread_create | Thread creation call reachable from function '$@', which may also be $@. | test.c:57:5:57:13 | thrd_func | thrd_func | test.c:18:3:18:13 | call to thrd_create | started as a thread |
11+
| test.c:81:3:81:13 | call to thrd_create | Thread creation call reachable from function '$@', which may also be $@. | test.c:48:7:48:18 | pthread_func | pthread_func | test.c:19:3:19:16 | call to pthread_create | started as a thread |
12+
| test.c:81:3:81:13 | call to thrd_create | Thread creation call reachable from function '$@', which may also be $@. | test.c:57:5:57:13 | thrd_func | thrd_func | test.c:18:3:18:13 | call to thrd_create | started as a thread |
13+
| test.c:82:3:82:16 | call to pthread_create | Thread creation call reachable from function '$@', which may also be $@. | test.c:48:7:48:18 | pthread_func | pthread_func | test.c:19:3:19:16 | call to pthread_create | started as a thread |
14+
| test.c:82:3:82:16 | call to pthread_create | Thread creation call reachable from function '$@', which may also be $@. | test.c:57:5:57:13 | thrd_func | thrd_func | test.c:18:3:18:13 | call to thrd_create | started as a thread |

c/misra/test/rules/DIR-5-3/test.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ thrd_t g1; // COMPLIANT
55
pthread_t g2; // COMPLIANT
66

77
void *pthread_func(void *arg);
8+
void *pthread_func_inner(void *arg);
89
int thrd_func(void *arg);
10+
int thrd_func_inner(void *arg);
911

1012
void make_threads_called_from_main(void);
1113
void func_called_from_main(void);
@@ -16,26 +18,26 @@ void main() {
1618
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT
1719
pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT
1820

19-
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT
20-
pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT
21+
thrd_create(&g1, &thrd_func_inner, NULL); // COMPLIANT
22+
pthread_create(&g2, NULL, &pthread_func_inner, NULL); // COMPLIANT
2123

2224
make_threads_called_from_main();
2325
func_called_from_main();
2426
make_threads_called_from_main_pthread_thrd();
2527
}
2628

2729
void make_threads_called_from_main() {
28-
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT
29-
pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT
30+
thrd_create(&g1, &thrd_func_inner, NULL); // COMPLIANT
31+
pthread_create(&g2, NULL, &pthread_func_inner, NULL); // COMPLIANT
3032
}
3133

3234
void func_called_from_main() {
3335
make_threads_called_from_func_called_from_main();
3436
}
3537

3638
void make_threads_called_from_func_called_from_main() {
37-
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT
38-
pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT
39+
thrd_create(&g1, &thrd_func_inner, NULL); // COMPLIANT
40+
pthread_create(&g2, NULL, &pthread_func_inner, NULL); // COMPLIANT
3941
}
4042

4143
void make_threads_called_from_pthread_func(void);
@@ -44,43 +46,43 @@ void func_called_from_pthread_thrd(void);
4446
void make_threads_called_from_func_called_from_pthread_thrd(void);
4547

4648
void *pthread_func(void *arg) {
47-
thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT
48-
pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT
49+
thrd_create(&g1, &thrd_func_inner, NULL); // NON-COMPLIANT
50+
pthread_create(&g2, NULL, &pthread_func_inner, NULL); // NON-COMPLIANT
4951

5052
make_threads_called_from_pthread_func();
5153
func_called_from_pthread_thrd();
5254
make_threads_called_from_main_pthread_thrd();
5355
}
5456

5557
int thrd_func(void *arg) {
56-
thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT
57-
pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT
58+
thrd_create(&g1, &thrd_func_inner, NULL); // NON-COMPLIANT
59+
pthread_create(&g2, NULL, &pthread_func_inner, NULL); // NON-COMPLIANT
5860

5961
make_threads_called_from_thrd_func();
6062
func_called_from_pthread_thrd();
6163
make_threads_called_from_main_pthread_thrd();
6264
}
6365

6466
void make_threads_called_from_thrd_func(void) {
65-
thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT
66-
pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT
67+
thrd_create(&g1, &thrd_func_inner, NULL); // NON-COMPLIANT
68+
pthread_create(&g2, NULL, &pthread_func_inner, NULL); // NON-COMPLIANT
6769
}
6870

6971
void func_called_from_pthread_thrd(void) {
7072
make_threads_called_from_func_called_from_pthread_thrd();
7173
}
7274

7375
void make_threads_called_from_func_called_from_pthread_thrd(void) {
74-
thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT
75-
pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT
76+
thrd_create(&g1, &thrd_func_inner, NULL); // NON-COMPLIANT
77+
pthread_create(&g2, NULL, &pthread_func_inner, NULL); // NON-COMPLIANT
7678
}
7779

7880
void make_threads_called_from_main_pthread_thrd() {
79-
thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT
80-
pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT
81+
thrd_create(&g1, &thrd_func_inner, NULL); // NON-COMPLIANT
82+
pthread_create(&g2, NULL, &pthread_func_inner, NULL); // NON-COMPLIANT
8183
}
8284

8385
void make_threads_not_called_by_anyone() {
84-
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT
85-
pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT
86+
thrd_create(&g1, &thrd_func_inner, NULL); // COMPLIANT
87+
pthread_create(&g2, NULL, &pthread_func_inner, NULL); // COMPLIANT
8688
}

0 commit comments

Comments
 (0)