Re: [PATCH v5 4/4] mm: Use ARRAY_END() instead of open-coding it

From: Alejandro Colomar

Date: Mon Dec 22 2025 - 20:07:32 EST


Hi Kees,

On Mon, Dec 22, 2025 at 03:21:21PM -0800, Kees Cook wrote:
> > Now that the first patch set has been merged, I'm working on a second
> > round.
> >
> > I've written a semantic patch:
> >
> > $ cat src/spatch/array_end.sp
> > @@
> > expression a;
> > @@
> >
> > - a + ARRAY_SIZE(a)
> > + ARRAY_END(a)
> >
> > @@
> > expression a;
> > @@
> >
> > - ARRAY_SIZE(a) + a
> > + ARRAY_END(a)
>
> I think you can add parens which will be silently removed but gain you
> the commutative behavior:

Ahhh, thanks! I was wondering how I could get commutative behavior.

> @@
> expression a;
> @@
>
> - (ARRAY_SIZE(a) + a)
> + ARRAY_END(a)
>
> I *think* that'll cover "a + ARRAY_SIZE(a)" too.

Yup, it works. :)

> Anyway, looks good!

Thanks!

> You could send it directly to Linus at the end of
> the next rc1, and he may take it.

I'll send a draft before that, just for you to review the actual patch.

> If not, you'll want to split the patch
> up and send to subsystems after ARRAY_END is in Linus's tree. I use this
> tool to split a large single patch into per-subsystem patches:
> https://github.com/kees/kernel-tools/blob/trunk/split-on-maintainer

Okay. I can do both, anyway.


Have a lovely night!
Alex

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

Attachment: signature.asc
Description: PGP signature