Skip to content

Commit 10bf70e

Browse files
committed
SIG31-C: Improve performance
Remove unintential cross product on target.
1 parent a498523 commit 10bf70e

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

c/cert/src/rules/SIG31-C/DoNotAccessSharedObjectsInSignalHandlers.ql

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,19 @@ import codingstandards.c.Signal
2121
*/
2222
class UnsafeSharedVariableAccess extends VariableAccess {
2323
UnsafeSharedVariableAccess() {
24-
// static or thread local storage duration
25-
(
26-
this.getTarget() instanceof StaticStorageDurationVariable or
27-
this.getTarget().isThreadLocal()
28-
) and
2924
// excluding `volatile sig_atomic_t` type
3025
not this.getType().(SigAtomicType).isVolatile() and
31-
// excluding lock-free atomic objects
32-
not exists(MacroInvocation mi, VariableAccess va |
33-
mi.getMacroName() = "atomic_is_lock_free" and
34-
mi.getExpr().getChild(0) = va.getEnclosingElement*() and
35-
va.getTarget() = this.getTarget()
26+
exists(Variable target | target = this.getTarget() |
27+
// static or thread local storage duration
28+
(
29+
target instanceof StaticStorageDurationVariable or
30+
target.isThreadLocal()
31+
) and
32+
// excluding lock-free atomic objects
33+
not exists(MacroInvocation mi, VariableAccess va | va.getTarget() = target |
34+
mi.getMacroName() = "atomic_is_lock_free" and
35+
mi.getExpr().getChild(0) = va.getEnclosingElement*()
36+
)
3637
)
3738
}
3839
}

0 commit comments

Comments
 (0)