-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix format, remove unneeded test complexity
- Loading branch information
1 parent
fb3c5e7
commit 20bae20
Showing
3 changed files
with
57 additions
and
66 deletions.
There are no files selected for viewing
32 changes: 16 additions & 16 deletions
32
c/misra/test/rules/DIR-5-3/BannedDynamicThreadCreation.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | |
28 changes: 14 additions & 14 deletions
28
c/misra/test/rules/DIR-5-3/ThreadCreatedByThread.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | | ||
| 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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,86 @@ | ||
#include "threads.h" | ||
#include "pthread.h" | ||
#include "threads.h" | ||
|
||
thrd_t g1; // COMPLIANT | ||
thrd_t g1; // COMPLIANT | ||
pthread_t g2; // COMPLIANT | ||
thrd_t g3[10]; // COMPLIANT | ||
pthread_t g4[10]; // COMPLIANT | ||
|
||
struct { | ||
thrd_t m1; // COMPLIANT | ||
pthread_t m2; // COMPLIANT | ||
} g7; | ||
|
||
void* pthread_func(void* arg); | ||
int thrd_func(void* arg); | ||
void *pthread_func(void *arg); | ||
int thrd_func(void *arg); | ||
|
||
void make_threads_called_from_main(void); | ||
void func_called_from_main(void); | ||
void make_threads_called_from_func_called_from_main(void); | ||
void make_threads_called_from_main_pthread_thrd(void); | ||
|
||
void main() { | ||
// Main starting top level threads -- ok. | ||
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT | ||
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT | ||
pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT | ||
|
||
// Starting thread in pool -- ok. | ||
thrd_create(&g3[0], &thrd_func, NULL); // COMPLIANT | ||
pthread_create(&g4[0], NULL, &pthread_func, NULL); // COMPLIANT | ||
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT | ||
pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT | ||
|
||
make_threads_called_from_main(); | ||
func_called_from_main(); | ||
make_threads_called_from_main_pthread_thrd(); | ||
} | ||
|
||
void make_threads_called_from_main() { | ||
thrd_create(&g3[0], &thrd_func, NULL); // COMPLIANT | ||
pthread_create(&g4[0], NULL, &pthread_func, NULL); // COMPLIANT | ||
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT | ||
pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT | ||
} | ||
|
||
void func_called_from_main() { | ||
make_threads_called_from_func_called_from_main(); | ||
make_threads_called_from_func_called_from_main(); | ||
} | ||
|
||
void make_threads_called_from_func_called_from_main() { | ||
thrd_create(&g3[0], &thrd_func, NULL); // COMPLIANT | ||
pthread_create(&g4[0], NULL, &pthread_func, NULL); // COMPLIANT | ||
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT | ||
pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT | ||
} | ||
|
||
void make_threads_called_from_pthread_func(void); | ||
void make_threads_called_from_thrd_func(void); | ||
void func_called_from_pthread_thrd(void); | ||
void make_threads_called_from_func_called_from_pthread_thrd(void); | ||
|
||
void* pthread_func(void* arg) { | ||
thrd_create(&g3[0], &thrd_func, NULL); // NON-COMPLIANT | ||
pthread_create(&g4[0], NULL, &pthread_func, NULL); // NON-COMPLIANT | ||
void *pthread_func(void *arg) { | ||
thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT | ||
pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT | ||
|
||
make_threads_called_from_pthread_func(); | ||
func_called_from_pthread_thrd(); | ||
make_threads_called_from_main_pthread_thrd(); | ||
} | ||
|
||
int thrd_func(void* arg) { | ||
thrd_create(&g3[0], &thrd_func, NULL); // NON-COMPLIANT | ||
pthread_create(&g4[0], NULL, &pthread_func, NULL); // NON-COMPLIANT | ||
int thrd_func(void *arg) { | ||
thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT | ||
pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT | ||
|
||
make_threads_called_from_thrd_func(); | ||
func_called_from_pthread_thrd(); | ||
make_threads_called_from_main_pthread_thrd(); | ||
} | ||
|
||
void make_threads_called_from_thrd_func(void) { | ||
thrd_create(&g3[0], &thrd_func, NULL); // NON-COMPLIANT | ||
pthread_create(&g4[0], NULL, &pthread_func, NULL); // NON-COMPLIANT | ||
thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT | ||
pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT | ||
} | ||
|
||
void func_called_from_pthread_thrd(void) { | ||
make_threads_called_from_func_called_from_pthread_thrd(); | ||
make_threads_called_from_func_called_from_pthread_thrd(); | ||
} | ||
|
||
void make_threads_called_from_func_called_from_pthread_thrd(void) { | ||
thrd_create(&g3[0], &thrd_func, NULL); // NON-COMPLIANT | ||
pthread_create(&g4[0], NULL, &pthread_func, NULL); // NON-COMPLIANT | ||
thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT | ||
pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT | ||
} | ||
|
||
void make_threads_called_from_main_pthread_thrd() { | ||
thrd_create(&g3[0], &thrd_func, NULL); // NON-COMPLIANT | ||
pthread_create(&g4[0], NULL, &pthread_func, NULL); // NON-COMPLIANT | ||
thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT | ||
pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT | ||
} | ||
|
||
void make_threads_not_called_by_anyone() { | ||
thrd_create(&g3[0], &thrd_func, NULL); // COMPLIANT | ||
pthread_create(&g4[0], NULL, &pthread_func, NULL); // COMPLIANT | ||
thrd_create(&g1, &thrd_func, NULL); // COMPLIANT | ||
pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT | ||
} |