Re: [cocci] [PATCH] scripts/coccinelle: Add script for using ARRAY_END()

Julia Lawall <[email protected]>
Newsgroups org.kernel.vger.kernel-janitors,fr.inria.cocci,org.kernel.vger.linux-kernel
Message-ID <[email protected]>

On Mon, 9 Mar 2026, Markus Elfring wrote:

> …
> > This script makes it easy to find more places where that macro should be
> > used.
>
> See also:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.0-rc3#n94
>
>
> …
> > +++ b/scripts/coccinelle/misc/array_end.cocci
> > @@ -0,0 +1,93 @@
> …
>
>
> > +// Confidence: ???
>
> I hope that a more reasonable value can be determined for this information.
>
>
> …
> > +// Comments:
>
> Please omit such an empty field.
>
>
> …
> > +@i@
> > +@@
> > +
> > +#include <linux/kernel.h>
>
> I doubt that such an SmPL rule would be required.
>
>
> > +
> > +//----------------------------------------------------------
> > +//  For context mode
> > +//----------------------------------------------------------
> > +
>
> Please omit such extra comment lines.

No problem to put such comments.

>
>
> > +@depends on i&&context@
> > +type T;
> > +T[] a;
> > +expression b;
> > +@@
> > +(
> > +* (a + ARRAY_SIZE(a))
> > +|
> > +* (&a[0] + ARRAY_SIZE(a))
> > +|
> > +* (&a[ARRAY_SIZE(a)])
> > +|
> > +* (&a[ARRAY_SIZE(a) - b])
> > +)
>
> Extra space characters may be omitted directly after SmPL asterisks.

No concern about the spaces either.

>
>
> …
> > +@r depends on (org || report)@
>
> You may omit parentheses here.
>
>
> …
> > +@script:python depends on report@
> > +p << r.p;
> > +@@
> > +
> > +msg="WARNING: Use ARRAY_END"
> > +coccilib.report.print_report(p[0], msg)
>
> Would the following command variant be a bit nicer?
>
> coccilib.report.print_report(p[0], "WARNING: opportunity for ARRAY_END()")

Either way.

julia
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.