Skip to content

Commit 20bae20

Browse files
Fix format, remove unneeded test complexity
1 parent fb3c5e7 commit 20bae20

File tree

3 files changed

+57
-66
lines changed

3 files changed

+57
-66
lines changed
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
| test.c:37:3:37:13 | call to thrd_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:36:6:36:34 | make_threads_called_from_main | make_threads_called_from_main |
2-
| test.c:38:3:38:16 | call to pthread_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:36:6:36:34 | make_threads_called_from_main | make_threads_called_from_main |
3-
| test.c:46:3:46:13 | call to thrd_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:45:6:45:51 | make_threads_called_from_func_called_from_main | make_threads_called_from_func_called_from_main |
4-
| test.c:47:3:47:16 | call to pthread_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:45:6:45:51 | make_threads_called_from_func_called_from_main | make_threads_called_from_func_called_from_main |
5-
| test.c:56:3:56:13 | call to thrd_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:55:7:55:18 | pthread_func | pthread_func |
6-
| test.c:57:3:57:16 | call to pthread_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:55:7:55:18 | pthread_func | pthread_func |
7-
| test.c:65:3:65:13 | call to thrd_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:64:5:64:13 | thrd_func | thrd_func |
8-
| test.c:66:3:66:16 | call to pthread_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:64:5:64:13 | thrd_func | thrd_func |
9-
| test.c:74:3:74:13 | call to thrd_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:73:6:73:39 | make_threads_called_from_thrd_func | make_threads_called_from_thrd_func |
10-
| test.c:75:3:75:16 | call to pthread_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:73:6:73:39 | make_threads_called_from_thrd_func | make_threads_called_from_thrd_func |
11-
| test.c:83:3:83:13 | call to thrd_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:82:6:82:59 | make_threads_called_from_func_called_from_pthread_thrd | make_threads_called_from_func_called_from_pthread_thrd |
12-
| test.c:84:3:84:16 | call to pthread_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:82:6:82:59 | make_threads_called_from_func_called_from_pthread_thrd | make_threads_called_from_func_called_from_pthread_thrd |
13-
| test.c:88:3:88:13 | call to thrd_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:87:6:87:47 | make_threads_called_from_main_pthread_thrd | make_threads_called_from_main_pthread_thrd |
14-
| test.c:89:3:89:16 | call to pthread_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:87:6:87:47 | make_threads_called_from_main_pthread_thrd | make_threads_called_from_main_pthread_thrd |
15-
| test.c:93:3:93:13 | call to thrd_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:92:6:92:38 | make_threads_not_called_by_anyone | make_threads_not_called_by_anyone |
16-
| test.c:94:3:94:16 | call to pthread_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:92:6:92:38 | make_threads_not_called_by_anyone | make_threads_not_called_by_anyone |
1+
| test.c:28:3:28:13 | call to thrd_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:27:6:27:34 | make_threads_called_from_main | make_threads_called_from_main |
2+
| test.c:29:3:29:16 | call to pthread_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:27:6:27:34 | make_threads_called_from_main | make_threads_called_from_main |
3+
| test.c:37:3:37:13 | call to thrd_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:36:6:36:51 | make_threads_called_from_func_called_from_main | make_threads_called_from_func_called_from_main |
4+
| test.c:38:3:38:16 | call to pthread_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:36:6:36:51 | make_threads_called_from_func_called_from_main | make_threads_called_from_func_called_from_main |
5+
| test.c:47:3:47:13 | call to thrd_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:46:7:46:18 | pthread_func | pthread_func |
6+
| test.c:48:3:48:16 | call to pthread_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:46:7:46:18 | pthread_func | pthread_func |
7+
| test.c:56:3:56:13 | call to thrd_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:55:5:55:13 | thrd_func | thrd_func |
8+
| test.c:57:3:57:16 | call to pthread_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:55:5:55:13 | thrd_func | thrd_func |
9+
| test.c:65:3:65:13 | call to thrd_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:64:6:64:39 | make_threads_called_from_thrd_func | make_threads_called_from_thrd_func |
10+
| test.c:66:3:66:16 | call to pthread_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:64:6:64:39 | make_threads_called_from_thrd_func | make_threads_called_from_thrd_func |
11+
| test.c:74:3:74:13 | call to thrd_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:73:6:73:59 | make_threads_called_from_func_called_from_pthread_thrd | make_threads_called_from_func_called_from_pthread_thrd |
12+
| test.c:75:3:75:16 | call to pthread_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:73:6:73:59 | make_threads_called_from_func_called_from_pthread_thrd | make_threads_called_from_func_called_from_pthread_thrd |
13+
| test.c:79:3:79:13 | call to thrd_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:78:6:78:47 | make_threads_called_from_main_pthread_thrd | make_threads_called_from_main_pthread_thrd |
14+
| test.c:80:3:80:16 | call to pthread_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:78:6:78:47 | make_threads_called_from_main_pthread_thrd | make_threads_called_from_main_pthread_thrd |
15+
| test.c:84:3:84:13 | call to thrd_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:83:6:83:38 | make_threads_not_called_by_anyone | make_threads_not_called_by_anyone |
16+
| test.c:85:3:85:16 | call to pthread_create | Possible dynamic creation of thread outside initialization in function '$@'. | test.c:83:6:83:38 | make_threads_not_called_by_anyone | make_threads_not_called_by_anyone |
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
| test.c:56:3:56:13 | call to thrd_create | Thread creation call reachable from threaded function '$@'. | test.c:55:7:55:18 | pthread_func | pthread_func |
2-
| test.c:57:3:57:16 | call to pthread_create | Thread creation call reachable from threaded function '$@'. | test.c:55:7:55:18 | pthread_func | pthread_func |
3-
| test.c:65:3:65:13 | call to thrd_create | Thread creation call reachable from threaded function '$@'. | test.c:64:5:64:13 | thrd_func | thrd_func |
4-
| test.c:66:3:66:16 | call to pthread_create | Thread creation call reachable from threaded function '$@'. | test.c:64:5:64:13 | thrd_func | thrd_func |
5-
| test.c:74:3:74:13 | call to thrd_create | Thread creation call reachable from threaded function '$@'. | test.c:64:5:64:13 | thrd_func | thrd_func |
6-
| test.c:75:3:75:16 | call to pthread_create | Thread creation call reachable from threaded function '$@'. | test.c:64:5:64:13 | thrd_func | thrd_func |
7-
| test.c:83:3:83:13 | call to thrd_create | Thread creation call reachable from threaded function '$@'. | test.c:55:7:55:18 | pthread_func | pthread_func |
8-
| test.c:83:3:83:13 | call to thrd_create | Thread creation call reachable from threaded function '$@'. | test.c:64:5:64:13 | thrd_func | thrd_func |
9-
| test.c:84:3:84:16 | call to pthread_create | Thread creation call reachable from threaded function '$@'. | test.c:55:7:55:18 | pthread_func | pthread_func |
10-
| test.c:84:3:84:16 | call to pthread_create | Thread creation call reachable from threaded function '$@'. | test.c:64:5:64:13 | thrd_func | thrd_func |
11-
| test.c:88:3:88:13 | call to thrd_create | Thread creation call reachable from threaded function '$@'. | test.c:55:7:55:18 | pthread_func | pthread_func |
12-
| test.c:88:3:88:13 | call to thrd_create | Thread creation call reachable from threaded function '$@'. | test.c:64:5:64:13 | thrd_func | thrd_func |
13-
| test.c:89:3:89:16 | call to pthread_create | Thread creation call reachable from threaded function '$@'. | test.c:55:7:55:18 | pthread_func | pthread_func |
14-
| test.c:89:3:89:16 | call to pthread_create | Thread creation call reachable from threaded function '$@'. | test.c:64:5:64:13 | thrd_func | thrd_func |
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 |

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

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,86 @@
1-
#include "threads.h"
21
#include "pthread.h"
2+
#include "threads.h"
33

4-
thrd_t g1; // COMPLIANT
4+
thrd_t g1; // COMPLIANT
55
pthread_t g2; // COMPLIANT
6-
thrd_t g3[10]; // COMPLIANT
7-
pthread_t g4[10]; // COMPLIANT
86

9-
struct {
10-
thrd_t m1; // COMPLIANT
11-
pthread_t m2; // COMPLIANT
12-
} g7;
13-
14-
void* pthread_func(void* arg);
15-
int thrd_func(void* arg);
7+
void *pthread_func(void *arg);
8+
int thrd_func(void *arg);
169

1710
void make_threads_called_from_main(void);
1811
void func_called_from_main(void);
1912
void make_threads_called_from_func_called_from_main(void);
2013
void make_threads_called_from_main_pthread_thrd(void);
2114

2215
void main() {
23-
// Main starting top level threads -- ok.
24-
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT
16+
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT
2517
pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT
2618

27-
// Starting thread in pool -- ok.
28-
thrd_create(&g3[0], &thrd_func, NULL); // COMPLIANT
29-
pthread_create(&g4[0], NULL, &pthread_func, NULL); // COMPLIANT
19+
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT
20+
pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT
3021

3122
make_threads_called_from_main();
3223
func_called_from_main();
3324
make_threads_called_from_main_pthread_thrd();
3425
}
3526

3627
void make_threads_called_from_main() {
37-
thrd_create(&g3[0], &thrd_func, NULL); // COMPLIANT
38-
pthread_create(&g4[0], NULL, &pthread_func, NULL); // COMPLIANT
28+
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT
29+
pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT
3930
}
4031

4132
void func_called_from_main() {
42-
make_threads_called_from_func_called_from_main();
33+
make_threads_called_from_func_called_from_main();
4334
}
4435

4536
void make_threads_called_from_func_called_from_main() {
46-
thrd_create(&g3[0], &thrd_func, NULL); // COMPLIANT
47-
pthread_create(&g4[0], NULL, &pthread_func, NULL); // COMPLIANT
37+
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT
38+
pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT
4839
}
4940

5041
void make_threads_called_from_pthread_func(void);
5142
void make_threads_called_from_thrd_func(void);
5243
void func_called_from_pthread_thrd(void);
5344
void make_threads_called_from_func_called_from_pthread_thrd(void);
5445

55-
void* pthread_func(void* arg) {
56-
thrd_create(&g3[0], &thrd_func, NULL); // NON-COMPLIANT
57-
pthread_create(&g4[0], NULL, &pthread_func, NULL); // NON-COMPLIANT
46+
void *pthread_func(void *arg) {
47+
thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT
48+
pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT
5849

5950
make_threads_called_from_pthread_func();
6051
func_called_from_pthread_thrd();
6152
make_threads_called_from_main_pthread_thrd();
6253
}
6354

64-
int thrd_func(void* arg) {
65-
thrd_create(&g3[0], &thrd_func, NULL); // NON-COMPLIANT
66-
pthread_create(&g4[0], NULL, &pthread_func, NULL); // NON-COMPLIANT
55+
int thrd_func(void *arg) {
56+
thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT
57+
pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT
6758

6859
make_threads_called_from_thrd_func();
6960
func_called_from_pthread_thrd();
7061
make_threads_called_from_main_pthread_thrd();
7162
}
7263

7364
void make_threads_called_from_thrd_func(void) {
74-
thrd_create(&g3[0], &thrd_func, NULL); // NON-COMPLIANT
75-
pthread_create(&g4[0], NULL, &pthread_func, NULL); // NON-COMPLIANT
65+
thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT
66+
pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT
7667
}
7768

7869
void func_called_from_pthread_thrd(void) {
79-
make_threads_called_from_func_called_from_pthread_thrd();
70+
make_threads_called_from_func_called_from_pthread_thrd();
8071
}
8172

8273
void make_threads_called_from_func_called_from_pthread_thrd(void) {
83-
thrd_create(&g3[0], &thrd_func, NULL); // NON-COMPLIANT
84-
pthread_create(&g4[0], NULL, &pthread_func, NULL); // NON-COMPLIANT
74+
thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT
75+
pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT
8576
}
8677

8778
void make_threads_called_from_main_pthread_thrd() {
88-
thrd_create(&g3[0], &thrd_func, NULL); // NON-COMPLIANT
89-
pthread_create(&g4[0], NULL, &pthread_func, NULL); // NON-COMPLIANT
79+
thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT
80+
pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT
9081
}
9182

9283
void make_threads_not_called_by_anyone() {
93-
thrd_create(&g3[0], &thrd_func, NULL); // COMPLIANT
94-
pthread_create(&g4[0], NULL, &pthread_func, NULL); // COMPLIANT
84+
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT
85+
pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT
9586
}

0 commit comments

Comments
 (0)