scripts/coccinelle: improve efficiency of array_end.cocci

* Add disable zero_multiple_format to each rule to avoid considering
the possibility that an array index is expressed using '\0'
* Omit outer parentheses on context and org/report rules that
only match ubt don't transform, since matching a subterm gives
the same result whether or not the parentheses are present.

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
This commit is contained in:
Julia Lawall 2026-09-27 11:16:22 +02:00
parent 6b828a87a6
commit 14be5faa8b

View File

@ -10,22 +10,22 @@ virtual context
virtual org
virtual report
@depends on context@
@depends on context disable zero_multiple_format@
type T;
T[] a;
expression b;
@@
(
* (a + ARRAY_SIZE(a))
* a + ARRAY_SIZE(a)
|
* (&a[0] + ARRAY_SIZE(a))
* &a[0] + ARRAY_SIZE(a)
|
* (&a[ARRAY_SIZE(a)])
* &a[ARRAY_SIZE(a)]
|
* (&a[ARRAY_SIZE(a) - b])
* &a[ARRAY_SIZE(a) - b]
)
@depends on patch@
@depends on patch disable zero_multiple_format@
type T;
T[] a;
expression b;
@ -44,20 +44,20 @@ expression b;
+ ARRAY_END(a) - b
)
@r depends on org || report@
@r depends on org || report disable zero_multiple_format@
type T;
T[] a;
expression b;
position p;
@@
(
(a@p + ARRAY_SIZE(a))
a@p + ARRAY_SIZE(a)
|
(&a[0]@p + ARRAY_SIZE(a))
&a[0]@p + ARRAY_SIZE(a)
|
(&a[ARRAY_SIZE(a)]@p)
&a[ARRAY_SIZE(a)]@p
|
(&a[ARRAY_SIZE(a)@p - b])
&a[ARRAY_SIZE(a)@p - b]
)
@script:python depends on org@