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

Alejandro Colomar <[email protected]> Mon, 9 Mar 2026 15:32:20 +0100
Newsgroups fr.inria.cocci,org.kernel.vger.kernel-janitors,org.kernel.vger.linux-kernel
Message-ID <aa7XD-rk_KWQvTQX@devuan>
Hi Markus,

On 2026-03-09T15:05:08+0100, Markus Elfring wrote:
> …
> > ---
> >  scripts/coccinelle/misc/array_end.cocci | 74 +++++++++++++++++++++++++
> …
> 
> Some contributors would appreciate patch version descriptions.
> https://lore.kernel.org/all/?q=%22This+looks+like+a+new+version+of+a+previously+submitted+patch%22
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.0-rc3#n310

I replied to all of your comments, and said how I would address them, in
reply to v1.  This v2 is in-reply-to v1, so that that sub-thread is easy
to find.  And at the bottom is a range-diff where you can find all the
exact changes from v1 to v2.

I could have noted in plain English the changes from v1 to v2, but
I thought it might be a bit redundant.

> May a subdirectory name be omitted from the subject prefix?
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/scripts/coccinelle/

Yeah, we could do that.  Here's what I checked for writing the subject
prefix:

	$ git log --oneline --author Lawall torvalds/master scripts/coccinelle/misc/ 
	f01701ce update Coccinelle URL
	92b2dada scripts/coccinelle: drop bugon.cocci
	c3003315 scripts: coccinelle: boolinit: drop warnings on named constants
	518d8a56 scripts: coccinelle: Correct warning message
	b825b432 scripts: coccinelle: only suggest true/false in files that already use>
	937c812d coccinelle: orplus: reorganize to improve performance
	69c4907b Coccinelle: use false positive annotation
	f75621c6 coccinelle: bugon: reduce rule applicability
	c7eaa887 Coccinelle: array_size: reduce rule applicability
	8f551bef Coccinelle: reduce rule applicability
	74a8478f coccinelle: misc: move constants to the right
	932058a5 coccinelle: misc: semantic patch to delete overly complex return code >
	24f0c2d6 scripts/coccinelle: find constant additions that could be bit ors
	ad99ac2f scripts/coccinelle/misc/warn.cocci: use WARN
	2cbd0825 scripts/coccinelle: sizeof of pointer
	4619c2b8 scripts/coccinelle: address test is always true
	89910581 coccinelle: semantic patch for bool issues
	4a05f067 coccinelle: semantic patch to check for PTR_ERR after reassignment
	29a36d4d scripts/coccinelle: improve the coverage of some semantic patches
	a1087ef6 scripts/coccinelle: update for compatability with Coccinelle 0.2.4

Since the latest line and a decent amount of lines have
"scripts/coccinelle", I picked that.  I don't have a preference, so
please let me know what's the preferred one.  I tend to prefer more
explicit ones, even if slightly longer, but I'll take whatever the
maintainers' preference is.

The only one I didn't really like was the 'scripts: coccinelle:' one.
Paths are more readable if we're going to include all the
subdirectories.  But this is just my opinion.

> …
> > +// Comments: No known false positives, but has a few false negatives
> 
> Would such information motivate for any further software refinements?

Yes, if anyone here knows how to handle the false negatives and wants to
work with me on improving those, I'm very interested.

Here's one case which isn't caught, for example (which I expect will be
difficult to handle, if not impossible):

	@@ -2876,7 +2876,7 @@ static struct dentry *proc_##LSM##_attr_dir_lookup(struct 
	inode *dir, \
	 { \
		return proc_pident_lookup(dir, dentry, \
					  LSM##_attr_dir_stuff, \
	-                                 LSM##_attr_dir_stuff + ARRAY_SIZE(LSM##_attr_dir_stuff)); \
	+                                 ARRAY_END(LSM##_attr_dir_stuff)); \
	 } \
	 \
	 static const struct inode_operations proc_##LSM##_attr_dir_inode_ops = { \

I could research and find other false negatives.


Cheers,
Alex

-- 
<https://www.alejandro-colomar.es>
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmmu2e0ACgkQ64mZXMKQ
wqlWBQ/8C99MHd/FasCpExad6HTYSDNWnqLOhDVeLnAam8fliZai0EvveKOeRpNg
Cdzmj7ip3djHD8x+3z5pHS9HEXhZqvreN9sEM2uqK4AvNCQRLG+TLBcMai0sSiSu
XDWI7TgIKfvW4YumFHmvJv3IUj1SuNxva7yfrEueXZU548x7C37a9j2hGfNof3t2
SSWh/TQ2/cw3jmfViJwtTF55rjMGvBt1swto9iJAhKJI0x82tWWupmCcyTWrQqum
DApgmBJ/5Vx8RvCfdqQ4qssX7LGhFcf4JXoNLZsOPAk0ByfW8j1OZcjFnaHQc0Xd
njjfBfdcNvnBgk1f/snt107KLTj4O/Iq75Co1ey3+B1/0U79ymI4xL/d5eBLu2g8
l8v6kMC/+L12VTfPIvud8OwJ9daljQS5puCX9KPt1egL2UImQ295egKXl1NRAXdM
RdNgXdD5R7B2l9wZ8OuLHbrx4o/ox+mNrGwsfGc+wlWhztnXZcOOwmzsU6/Q12VC
Sfj6cwx1YZVgmuSITQKiOnAYIHiY2wts6Af/vb/4GsEWm4+RoswkJ6Ike4eYMfbL
clTZa6CpRnYnEOd4p24oNvemFs5AVuZDiAEq+R4AJFc66Yb6z7p8TZj8d3I/4951
EM7QilN59IJzv5ejkFKdql9UGy02k4AjL3u5PPrERbPn+TYHCpk=
=ue2C
-----END PGP SIGNATURE-----