Skip to content

Commit 8f521a5

Browse files
Format c tests, c ql files
1 parent 4623f33 commit 8f521a5

File tree

7 files changed

+47
-49
lines changed

7 files changed

+47
-49
lines changed

c/misra/src/rules/RULE-21-22/TgMathArgumentWithInvalidEssentialType.ql

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ string getAllowedTypesString(TgMathInvocation call) {
3434
else result = "essentially signed, unsigned, or real floating type"
3535
}
3636

37-
from TgMathInvocation call, Expr convertedArg, Expr unconverted, int argIndex, Type type, EssentialTypeCategory category
37+
from
38+
TgMathInvocation call, Expr convertedArg, Expr unconverted, int argIndex, Type type,
39+
EssentialTypeCategory category
3840
where
3941
not isExcluded(call, EssentialTypes2Package::tgMathArgumentWithInvalidEssentialTypeQuery()) and
4042
// We must handle conversions specially, as clang inserts casts in the macro body we want to ignore.

c/misra/src/rules/RULE-21-23/TgMathArgumentsWithDifferingStandardType.ql

+1-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ Type canonicalize(Type type) {
5858
else result = type
5959
}
6060

61-
Type getEffectiveStandardType(Expr e) {
62-
result = canonicalize(getPromotedType(e))
63-
}
61+
Type getEffectiveStandardType(Expr e) { result = canonicalize(getPromotedType(e)) }
6462

6563
from TgMathInvocation call, Type firstType
6664
where

c/misra/src/rules/RULE-21-25/InvalidMemoryOrderArgument.ql

+1-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ module MemoryOrderFlowConfig implements DataFlow::ConfigSig {
7777
}
7878

7979
predicate isSink(DataFlow::Node node) {
80-
exists(AtomicallySequencedCall call |
81-
call.getAMemoryOrderArgument() = node.asExpr()
82-
)
80+
exists(AtomicallySequencedCall call | call.getAMemoryOrderArgument() = node.asExpr())
8381
}
8482
}
8583

c/misra/test/rules/RULE-18-10/test.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ void f1(
5757
} p20,
5858

5959
// Unknown array length types:
60-
int p21[], // COMPLIANT
61-
int p22[][2], // COMPLIANT
62-
int (*p23)[], // COMPLIANT
60+
int p21[], // COMPLIANT
61+
int p22[][2], // COMPLIANT
62+
int (*p23)[], // COMPLIANT
6363
// int (*p24)[2][], // doesn't compile
6464
int (*p25)[][2], // COMPLIANT
6565

c/misra/test/rules/RULE-18-8/test.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void f1(int n,
2828
int p1[n], // COMPLIANT
2929
// Pointers to variably-modified types are not VLAs.
3030
int p2[n][n],
31-
int p3[], // array of unknown length is converted to pointer
31+
int p3[], // array of unknown length is converted to pointer
3232
int p4[][n] // array of unknown length are not VLAs.
3333
) {}
3434

c/misra/test/rules/RULE-21-22/test.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ void f1() {
322322
remquo(i, i, c); // COMPLIANT
323323

324324
/* Test casts */
325-
cos((char) i); // NON-COMPLIANT
326-
cos((int) c); // COMPLIANT
327-
cos((int) (char) i); // COMPLIANT
328-
cos((char) (int) c); // NON-COMPLIANT
325+
cos((char)i); // NON-COMPLIANT
326+
cos((int)c); // COMPLIANT
327+
cos((int)(char)i); // COMPLIANT
328+
cos((char)(int)c); // NON-COMPLIANT
329329
}

c/misra/test/rules/RULE-21-25/test.c

+34-34
Original file line numberDiff line numberDiff line change
@@ -21,52 +21,52 @@ void f(int p) {
2121
atomic_load_explicit(&l1, memory_order_release); // NON-COMPLIANT
2222

2323
// Implicit values:
24-
atomic_store(&l1, 0); // COMPLIANT
25-
atomic_load(&l1); // COMPLIANT
26-
atomic_flag_test_and_set(&l2); // COMPLIANT
27-
atomic_flag_clear(&l2); // COMPLIANT
28-
atomic_exchange(&l1, 0); // COMPLIANT
24+
atomic_store(&l1, 0); // COMPLIANT
25+
atomic_load(&l1); // COMPLIANT
26+
atomic_flag_test_and_set(&l2); // COMPLIANT
27+
atomic_flag_clear(&l2); // COMPLIANT
28+
atomic_exchange(&l1, 0); // COMPLIANT
2929
atomic_compare_exchange_strong(&l1, ptr, 1); // COMPLIANT
3030
atomic_compare_exchange_weak(&l1, ptr, 1); // COMPLIANT
31-
atomic_fetch_add(&l1, 0); // COMPLIANT
32-
atomic_fetch_sub(&l1, 0); // COMPLIANT
33-
atomic_fetch_or(&l1, 0); // COMPLIANT
34-
atomic_fetch_xor(&l1, 0); // COMPLIANT
35-
atomic_fetch_and(&l1, 0); // COMPLIANT
31+
atomic_fetch_add(&l1, 0); // COMPLIANT
32+
atomic_fetch_sub(&l1, 0); // COMPLIANT
33+
atomic_fetch_or(&l1, 0); // COMPLIANT
34+
atomic_fetch_xor(&l1, 0); // COMPLIANT
35+
atomic_fetch_and(&l1, 0); // COMPLIANT
3636

3737
// Compliant flowed values (one test per sink):
38-
atomic_store_explicit(&l1, 0, g1); // COMPLIANT
39-
atomic_load_explicit(&l1, g1); // COMPLIANT
40-
atomic_flag_test_and_set_explicit(&l2, g1); // COMPLIANT
41-
atomic_flag_clear_explicit(&l2, g1); // COMPLIANT
42-
atomic_exchange_explicit(&l1, 0, g1); // COMPLIANT
38+
atomic_store_explicit(&l1, 0, g1); // COMPLIANT
39+
atomic_load_explicit(&l1, g1); // COMPLIANT
40+
atomic_flag_test_and_set_explicit(&l2, g1); // COMPLIANT
41+
atomic_flag_clear_explicit(&l2, g1); // COMPLIANT
42+
atomic_exchange_explicit(&l1, 0, g1); // COMPLIANT
4343
atomic_compare_exchange_strong_explicit(&l1, ptr, 1, g1, g1); // COMPLIANT
4444
atomic_compare_exchange_weak_explicit(&l1, ptr, 1, g1, g1); // COMPLIANT
45-
atomic_fetch_add_explicit(&l1, 0, g1); // COMPLIANT
46-
atomic_fetch_sub_explicit(&l1, 0, g1); // COMPLIANT
47-
atomic_fetch_or_explicit(&l1, 0, g1); // COMPLIANT
48-
atomic_fetch_xor_explicit(&l1, 0, g1); // COMPLIANT
49-
atomic_fetch_and_explicit(&l1, 0, g1); // COMPLIANT
50-
atomic_thread_fence(g1); // COMPLIANT
51-
atomic_signal_fence(g1); // COMPLIANT
45+
atomic_fetch_add_explicit(&l1, 0, g1); // COMPLIANT
46+
atomic_fetch_sub_explicit(&l1, 0, g1); // COMPLIANT
47+
atomic_fetch_or_explicit(&l1, 0, g1); // COMPLIANT
48+
atomic_fetch_xor_explicit(&l1, 0, g1); // COMPLIANT
49+
atomic_fetch_and_explicit(&l1, 0, g1); // COMPLIANT
50+
atomic_thread_fence(g1); // COMPLIANT
51+
atomic_signal_fence(g1); // COMPLIANT
5252

5353
// Non-compliant flowed values (one test per sink):
54-
atomic_store_explicit(&l1, 0, g2); // NON-COMPLIANT
55-
atomic_load_explicit(&l1, g2); // NON-COMPLIANT
56-
atomic_flag_test_and_set_explicit(&l2, g2); // NON-COMPLIANT
57-
atomic_flag_clear_explicit(&l2, g2); // NON-COMPLIANT
58-
atomic_exchange_explicit(&l1, 0, g2); // NON-COMPLIANT
54+
atomic_store_explicit(&l1, 0, g2); // NON-COMPLIANT
55+
atomic_load_explicit(&l1, g2); // NON-COMPLIANT
56+
atomic_flag_test_and_set_explicit(&l2, g2); // NON-COMPLIANT
57+
atomic_flag_clear_explicit(&l2, g2); // NON-COMPLIANT
58+
atomic_exchange_explicit(&l1, 0, g2); // NON-COMPLIANT
5959
atomic_compare_exchange_strong_explicit(&l1, ptr, 1, g2, g1); // NON-COMPLIANT
6060
atomic_compare_exchange_strong_explicit(&l1, ptr, 1, g1, g2); // NON-COMPLIANT
6161
atomic_compare_exchange_weak_explicit(&l1, ptr, 1, g2, g1); // NON-COMPLIANT
6262
atomic_compare_exchange_weak_explicit(&l1, ptr, 1, g1, g2); // NON-COMPLIANT
63-
atomic_fetch_add_explicit(&l1, 0, g2); // NON-COMPLIANT
64-
atomic_fetch_sub_explicit(&l1, 0, g2); // NON-COMPLIANT
65-
atomic_fetch_or_explicit(&l1, 0, g2); // NON-COMPLIANT
66-
atomic_fetch_xor_explicit(&l1, 0, g2); // NON-COMPLIANT
67-
atomic_fetch_and_explicit(&l1, 0, g2); // NON-COMPLIANT
68-
atomic_thread_fence(g2); // NON-COMPLIANT
69-
atomic_signal_fence(g2); // NON-COMPLIANT
63+
atomic_fetch_add_explicit(&l1, 0, g2); // NON-COMPLIANT
64+
atomic_fetch_sub_explicit(&l1, 0, g2); // NON-COMPLIANT
65+
atomic_fetch_or_explicit(&l1, 0, g2); // NON-COMPLIANT
66+
atomic_fetch_xor_explicit(&l1, 0, g2); // NON-COMPLIANT
67+
atomic_fetch_and_explicit(&l1, 0, g2); // NON-COMPLIANT
68+
atomic_thread_fence(g2); // NON-COMPLIANT
69+
atomic_signal_fence(g2); // NON-COMPLIANT
7070

7171
// Non-compliant flowed values (one test per source):
7272
atomic_thread_fence(g2); // NON-COMPLIANT

0 commit comments

Comments
 (0)