Skip to content

Commit 9ee2af6

Browse files
Fix test issues
1 parent 3259d17 commit 9ee2af6

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

c/cert/test/rules/CON39-C/ThreadWasPreviouslyJoinedOrDetached.qlref

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
| test.c:7:18:7:39 | ATOMIC_VAR_INIT(value) | Atomic variable possibly referred to twice in an $@. | test.c:33:3:33:10 | ... += ... | expression |
22
| test.c:7:18:7:39 | ATOMIC_VAR_INIT(value) | Atomic variable possibly referred to twice in an $@. | test.c:34:3:34:13 | ... = ... | expression |
3-
| test.c:11:3:11:23 | atomic_store(a,b) | Atomic variable possibly referred to twice in an $@. | test.c:11:3:11:23 | atomic_store(a,b) | expression |
4-
| test.c:12:3:12:35 | atomic_store_explicit(a,b,c) | Atomic variable possibly referred to twice in an $@. | test.c:12:3:12:35 | atomic_store_explicit(a,b,c) | expression |
5-
| test.c:25:3:25:49 | atomic_compare_exchange_weak(a,b,c) | Atomic variable possibly referred to twice in an $@. | test.c:25:3:25:49 | atomic_compare_exchange_weak(a,b,c) | expression |
6-
| test.c:26:3:27:42 | atomic_compare_exchange_weak_explicit(a,b,c,d,e) | Atomic variable possibly referred to twice in an $@. | test.c:26:3:27:42 | atomic_compare_exchange_weak_explicit(a,b,c,d,e) | expression |
3+
| test.c:11:3:11:23 | atomic_store(object,desired) | Atomic variable possibly referred to twice in an $@. | test.c:11:3:11:23 | atomic_store(object,desired) | expression |
4+
| test.c:12:3:12:23 | atomic_store_explicit | Atomic variable possibly referred to twice in an $@. | test.c:12:3:12:23 | atomic_store_explicit | expression |
5+
| test.c:25:3:25:49 | atomic_compare_exchange_weak(object,expected,desired) | Atomic variable possibly referred to twice in an $@. | test.c:25:3:25:49 | atomic_compare_exchange_weak(object,expected,desired) | expression |
6+
| test.c:26:3:26:39 | atomic_compare_exchange_weak_explicit | Atomic variable possibly referred to twice in an $@. | test.c:26:3:26:39 | atomic_compare_exchange_weak_explicit | expression |
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| test.c:41:13:41:13 | x | Invalid access to member '$@' on atomic struct or union. | test.c:5:7:5:7 | x | x |
2-
| test.c:42:18:42:18 | x | Invalid access to member '$@' on atomic struct or union. | test.c:5:7:5:7 | x | x |
31
| test.c:43:13:43:13 | x | Invalid access to member '$@' on atomic struct or union. | test.c:5:7:5:7 | x | x |
42
| test.c:44:18:44:18 | x | Invalid access to member '$@' on atomic struct or union. | test.c:5:7:5:7 | x | x |
3+
| test.c:45:13:45:13 | x | Invalid access to member '$@' on atomic struct or union. | test.c:5:7:5:7 | x | x |
4+
| test.c:46:18:46:18 | x | Invalid access to member '$@' on atomic struct or union. | test.c:5:7:5:7 | x | x |

c/misra/test/rules/RULE-12-6/test.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "stdatomic.h"
22
#include "string.h"
33

4-
typedef struct s2 {
4+
typedef struct s1 {
55
int x;
66
} s1;
77

@@ -16,14 +16,16 @@ _Atomic int g3;
1616
void takeCopy(s1 p1);
1717

1818
void f1() {
19-
s1 *l1;
19+
s1 l1;
20+
s1 *l2;
2021
l1 = atomic_load(&atomic_s1); // COMPLIANT
2122
l1 = atomic_load(ptr_atomic_s1); // COMPLIANT
22-
l1 = atomic_load(&s1_atomic_ptr); // COMPLIANT
23-
l1->x = 4; // COMPLIANT
23+
l2 = atomic_load(&s1_atomic_ptr); // COMPLIANT
24+
l1.x = 4; // COMPLIANT
25+
l2->x = 4; // COMPLIANT
2426
atomic_store(&atomic_s1, l1); // COMPLIANT
2527
atomic_store(ptr_atomic_s1, l1); // COMPLIANT
26-
atomic_store(&s1_atomic_ptr, l1); // COMPLIANT
28+
atomic_store(&s1_atomic_ptr, l2); // COMPLIANT
2729

2830
// Undefined behavior, but not banned by this rule.
2931
memset(&atomic_s1, sizeof(atomic_s1), 0); // COMPLIANT
@@ -34,8 +36,8 @@ void f1() {
3436
takeCopy(*ptr_atomic_s1); // COMPLIANT
3537
atomic_s1 = (s1){0}; // COMPLIANT
3638
*ptr_atomic_s1 = (s1){0}; // COMPLIANT
37-
atomic_s1 = *l1; // COMPLIANT
38-
ptr_atomic_s1 = l1; // COMPLIANT
39+
atomic_s1 = *l2; // COMPLIANT
40+
ptr_atomic_s1 = l2; // COMPLIANT
3941

4042
// Banned: circumvents data-race protection, results in UB.
4143
atomic_s1.x; // NON-COMPLIANT
@@ -54,6 +56,6 @@ void f1() {
5456
memset(s1_atomic_ptr, sizeof(*s1_atomic_ptr), 0); // COMPLIANT
5557
takeCopy(*s1_atomic_ptr); // COMPLIANT
5658
*s1_atomic_ptr = (s1){0}; // COMPLIANT
57-
s1_atomic_ptr = l1; // COMPLIANT
59+
s1_atomic_ptr = l2; // COMPLIANT
5860
s1_atomic_ptr->x; // COMPLIANT
5961
}

0 commit comments

Comments
 (0)