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

From: Alejandro Colomar

Date: Mon Mar 09 2026 - 08:24:49 EST


Hi Julia,

On 2026-03-09T12:59:48+0100, Julia Lawall wrote:
> > > +
> > > +//----------------------------------------------------------
> > > +// For context mode
> > > +//----------------------------------------------------------
> > > +
> >
> > Please omit such extra comment lines.
>
> No problem to put such comments.

Okay; thanks! Although I tend to prefer without them, so I've removed
them. Also, a majority of existing scripts don't have them.

> > > +@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.

Okay; I've kept them, as the majority has them.

> > …
> > > +@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.

I've taken the suggestion. Thanks for the review!


Have a lovely day!
Alex

>
> julia


--
<https://www.alejandro-colomar.es>

Attachment: signature.asc
Description: PGP signature