Re: [cocci] [PATCH] scripts/coccinelle: Add script for using ARRAY_END()
Julia Lawall <[email protected]> Mon, 9 Mar 2026 12:59:48 +0100 (CET)
| Newsgroups | fr.inria.cocci,org.kernel.vger.kernel-janitors,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