From: Julia Lawall <julia.lawall@inria.fr>
To: Alejandro Colomar <alx@kernel.org>
Cc: Markus Elfring <Markus.Elfring@web.de>,
cocci@inria.fr, Nicolas Palix <nicolas.palix@imag.fr>,
LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org, Kees Cook <kees@kernel.org>
Subject: Re: [cocci] [PATCH] scripts/coccinelle: Add script for using ARRAY_END()
Date: Mon, 9 Mar 2026 13:21:23 +0100 (CET) [thread overview]
Message-ID: <f950c541-1c21-7d5-b7d7-1a14bb6e8a4@inria.fr> (raw)
In-Reply-To: <aa6vSvsp4J6InmiB@devuan>
[-- Attachment #1: Type: text/plain, Size: 5494 bytes --]
On Mon, 9 Mar 2026, Alejandro Colomar wrote:
> Hi Markus,
>
> On 2026-03-09T12:17:00+0100, 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
>
> Thanks!
>
> > …
> > > +++ 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.
>
> I don't know how the scale works. I know the script has a few false
> negatives, and AFAIK there are no false positives. To what level of
> confidence would that belong?
Probably high would be fine. The goal is mostly to indiacte whether the
results are most likely correct or whether they will require a lot of
study to know if everything is ok.
>
> Is that field a keyword, or may I be explicit such as with this?:
>
> // Confidence: no false positives, but a few false negatives
>
> Or maybe I should write that in Comments...
>
> > …
> > > +// Comments:
> >
> > Please omit such an empty field.
>
> Ok; thanks!
>
> $ grep -rh '^// Comments:' scripts/coccinelle/ | sort | uniq -c
> 34 // Comments:
> 2 // Comments: -
> 1 // Comments: -I ... -all_includes can give more complete results
> 1 // Comments: Comments on code can be deleted if near code that is removed.
> 1 // Comments: Some false positives on empty default cases in switch statements.
> 1 // Comments: requires at least Coccinelle 0.2.4, lex or parse error otherwise
> $ find scripts/coccinelle/ -type f | wc -l
> 76
>
>
> It seems around half of the existing scripts have that. You may want to
> remove those empty comments. I added it because the scripts I looked at
> do have it.
I don't require taht an empty comments field be removed.
> > …
> > > +@i@
> > > +@@
> > > +
> > > +#include <linux/kernel.h>
> >
> > I doubt that such an SmPL rule would be required.
>
> Okay, I'll remove it. Thanks!
I'm lacking context. You maye need this if the file doesn't already have
it. But it is hard to know if it could be include indirectly...
julia
>
> > > +
> > > +//----------------------------------------------------------
> > > +// For context mode
> > > +//----------------------------------------------------------
> > > +
> >
> > Please omit such extra comment lines.
>
> Agree. BTW, you may want to remove such lines from existing scripts:
>
> $ grep -r '^//.*For context mode' scripts/coccinelle/
> scripts/coccinelle/null/deref_null.cocci:// For context mode
> scripts/coccinelle/misc/boolconv.cocci:// For context mode
> scripts/coccinelle/misc/array_size.cocci:// For context mode
> scripts/coccinelle/misc/struct_size.cocci:// For context mode
> scripts/coccinelle/misc/newline_in_nl_msg.cocci:// For context mode
> scripts/coccinelle/misc/badty.cocci:// For context mode
> scripts/coccinelle/api/alloc/pool_zalloc-simple.cocci:// For context mode
> scripts/coccinelle/api/alloc/zalloc-simple.cocci:// For context mode
> scripts/coccinelle/api/alloc/alloc_cast.cocci:// For context mode
> scripts/coccinelle/api/pm_runtime.cocci:// For context mode
> scripts/coccinelle/api/resource_size.cocci:// For context mode
> scripts/coccinelle/api/vma_pages.cocci:// For context mode
>
> > > +@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.
>
> Good to know; thanks!
>
> Although most scripts seem to be using white space (space (164) or
> tab (26)) after the asterisk. Please confirm if you prefer it removed
> in new scripts. Only 39 scripts don't have white space after it.
>
> $ grep -rh '^\*' scripts/coccinelle/ | grep -o '^..' | sort | uniq -c
> 26 *
> 164 *
> 4 *(
> 1 *;
> 1 *E
> 1 *I
> 1 *P
> 2 *W
> 1 *\
> 1 *b
> 1 *c
> 3 *d
> 1 *e
> 4 *f
> 1 *g
> 2 *i
> 1 *l
> 4 *r
> 2 *s
> 1 *u
> 2 *w
> 5 *x
> $ grep -rh '^\*' scripts/coccinelle/ | grep -o '^.\s' | sort | uniq -c | hd
> 00000000 20 20 20 20 20 32 36 20 2a 09 0a 20 20 20 20 31 | 26 *.. 1|
> 00000010 36 34 20 2a 20 0a |64 * .|
> 00000016
> $ grep -rh '^\*' scripts/coccinelle/ | grep -o '^.\S' | wc -l
> 39
>
>
> > …
> > > +@r depends on (org || report)@
> >
> > You may omit parentheses here.
>
> Ok.
>
> > …
> > > +@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()")
>
> Sounds good.
>
> > By the way:
> > How do you think about to omit a cover letter for a single patch?
>
> Sounds reasonable. I like the cover letter as it holds the range-diff,
> which may become a bit confusing when it's in the same email as the
> patch, but maybe that's just me.
>
> I'll send v2 in a single email.
>
> >
> > Regards,
> > Markus
>
> Have a lovely day!
> Alex
>
> --
> <https://www.alejandro-colomar.es>
>
next prev parent reply other threads:[~2026-03-09 12:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1772752564.git.alx@kernel.org>
[not found] ` <f1c9dff525752dc5a839760269a1c96d6e0870b4.1772752564.git.alx@kernel.org>
2026-03-09 11:17 ` Markus Elfring
2026-03-09 11:59 ` Julia Lawall
2026-03-09 12:16 ` Alejandro Colomar
2026-03-09 12:10 ` Alejandro Colomar
2026-03-09 12:21 ` Julia Lawall [this message]
2026-03-09 12:27 ` Alejandro Colomar
[not found] ` <9fd8d3d1e7ef3efb6e6dae0972dd515ff02e42bd.1773058287.git.alx@kernel.org>
2026-03-09 14:05 ` [PATCH v2] " Markus Elfring
2026-03-09 14:32 ` Alejandro Colomar
2026-03-15 17:17 ` Alejandro Colomar
2026-03-15 17:54 ` Julia Lawall
2026-03-15 22:05 ` Alejandro Colomar
2026-03-16 7:18 ` [v2] " Markus Elfring
2026-03-16 10:39 ` Alejandro Colomar
2026-03-16 10:46 ` Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f950c541-1c21-7d5-b7d7-1a14bb6e8a4@inria.fr \
--to=julia.lawall@inria.fr \
--cc=Markus.Elfring@web.de \
--cc=alx@kernel.org \
--cc=cocci@inria.fr \
--cc=kees@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolas.palix@imag.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®