Skip to content

Commit 8403a4b

Browse files
Fix format
1 parent ae63dcb commit 8403a4b

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

c/misra/src/rules/RULE-13-2/UnsequencedAtomicReads.ql

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,20 @@ class AtomicAccessInFullExpressionOrdering extends Ordering::Configuration {
3333

3434
/**
3535
* A read of a variable specified as `_Atomic`.
36-
*
36+
*
3737
* Note, it may be accessed directly, or by passing its address into the std atomic functions.
3838
*/
3939
class AtomicVariableAccess extends VariableAccess {
4040
pragma[noinline]
41-
AtomicVariableAccess() {
42-
getTarget().getType().hasSpecifier("atomic")
43-
}
41+
AtomicVariableAccess() { getTarget().getType().hasSpecifier("atomic") }
4442

4543
/* Get the `atomic_<read|write>()` call this VarAccess occurs in. */
4644
FunctionCall getAtomicFunctionCall() {
4745
exists(AddressOfExpr addrParent, FunctionCall fc |
4846
fc.getTarget().getName().matches("__c11_atomic%") and
4947
addrParent = fc.getArgument(0) and
50-
addrParent.getAnOperand() = this
51-
and result = fc
48+
addrParent.getAnOperand() = this and
49+
result = fc
5250
)
5351
}
5452

@@ -59,8 +57,8 @@ class AtomicVariableAccess extends VariableAccess {
5957
result = getAtomicFunctionCall().getArgument(1)
6058
or
6159
exists(AssignExpr assign |
62-
assign.getLValue() = this
63-
and result = assign.getRValue()
60+
assign.getLValue() = this and
61+
result = assign.getRValue()
6462
)
6563
}
6664

@@ -75,8 +73,8 @@ class AtomicVariableAccess extends VariableAccess {
7573
}
7674

7775
from
78-
AtomicAccessInFullExpressionOrdering config, FullExpr e, Variable v,
79-
AtomicVariableAccess va1, AtomicVariableAccess va2
76+
AtomicAccessInFullExpressionOrdering config, FullExpr e, Variable v, AtomicVariableAccess va1,
77+
AtomicVariableAccess va2
8078
where
8179
not isExcluded(e, SideEffects3Package::unsequencedAtomicReadsQuery()) and
8280
e = va1.(ConstituentExpr).getFullExpr() and
@@ -89,6 +87,6 @@ where
8987
TaintTracking::localTaint(DataFlow::exprNode(va2.getARead()), DataFlow::exprNode(write))
9088
) and
9189
// Impose an ordering, show the first access.
92-
va1.getLocation().isBefore(va2.getLocation(), _)
93-
select e, "Atomic variable $@ has a $@ that is unsequenced with $@.",
94-
v, v.getName(), va1, "previous read", va2, "another read"
90+
va1.getLocation().isBefore(va2.getLocation(), _)
91+
select e, "Atomic variable $@ has a $@ that is unsequenced with $@.", v, v.getName(), va1,
92+
"previous read", va2, "another read"

c/misra/test/rules/RULE-13-2/test.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ void unsequenced_sideeffects2() {
4040

4141
void atomics() {
4242
_Atomic int a1, a2;
43-
int l3 = a1 + a2; // COMPLIANT
44-
int l4 = a1 + a1; // NON_COMPLIANT
45-
a1 = a1 + 1; // COMPLIANT
43+
int l3 = a1 + a2; // COMPLIANT
44+
int l4 = a1 + a1; // NON_COMPLIANT
45+
a1 = a1 + 1; // COMPLIANT
4646
atomic_load(&a1) + atomic_load(&a1); // NON_COMPLIANT
4747
atomic_load(&a1) + atomic_load(&a2); // COMPLIANT
4848
atomic_store(&a1, atomic_load(&a1)); // COMPLIANT
49-
atomic_store(&a1, a1); // COMPLIANT
49+
atomic_store(&a1, a1); // COMPLIANT
5050
}

0 commit comments

Comments
 (0)