coccinelle: Extend address test from ifaddr semantic patch to test expressions
authorJérémy LEFAURE <jeremy.lefaure@netatmo.com>
Fri, 1 Jul 2022 16:01:36 +0000 (16:01 +0000)
committerJulia Lawall <Julia.Lawall@inria.fr>
Sun, 3 Jul 2022 21:45:05 +0000 (23:45 +0200)
The test of an expression's address does not necessarily represent the
whole condition, it may only be a part of it. Also, an expression's
address is likely to be non-zero in every test expression, not only in
if statements.

This change aims at detecting an address test in more complex conditions
and not only in if statements.

Signed-off-by: Jérémy Lefaure <jeremy.lefaure@netatmo.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
scripts/coccinelle/misc/test_addr.cocci [moved from scripts/coccinelle/misc/ifaddr.cocci with 94% similarity]

similarity index 94%
rename from scripts/coccinelle/misc/ifaddr.cocci
rename to scripts/coccinelle/misc/test_addr.cocci
index fc92e8f..029db90 100644 (file)
@@ -14,12 +14,10 @@ virtual context
 
 @r@
 expression x;
-statement S1,S2;
 position p;
 @@
 
-*if@p (&x)
- S1 else S2
+*\(&x@p == NULL \| &x@p != NULL\)
 
 @script:python depends on org@
 p << r.p;