Re: [v2] scripts/coccinelle: Add script for using ARRAY_END()
From: Alejandro Colomar
Date: Mon Mar 16 2026 - 06:42:28 EST
Hi Markus,
On 2026-03-16T08:18:17+0100, Markus Elfring wrote:
[...]
> …
> > +++ b/arch/powerpc/kernel/rtas.c
> > @@ -555,10 +555,8 @@ static struct rtas_function rtas_function_table[] __ro_after_init = {
> > },
> > };
> >
> > -#define for_each_rtas_function(funcp) \
> > - for (funcp = &rtas_function_table[0]; \
> > - funcp < &rtas_function_table[ARRAY_SIZE(rtas_function_table)]; \
> > - ++funcp)
> > +#define for_each_rtas_function(f) \
> > + for (f = rtas_function_table; f < ARRAY_END(rtas_function_table); ++f)
>
> Are there development challenges to reconsider for macro definitions?
I've seen cases within macros that were correctly reported, so it's not
an issue with macros.
> …
> > +++ b/drivers/net/wireless/intel/iwlwifi/mei/net.c
> > @@ -43,7 +43,7 @@ static bool iwl_mei_rx_filter_eth(const struct ethhdr *ethhdr,
> > return false;
> >
> > for (filt = &filters->eth_filters[0];
> > - filt < &filters->eth_filters[0] + ARRAY_SIZE(filters->eth_filters);
> > + filt < ARRAY_END(filters->eth_filters);
> > filt++) {
> > /* Assume there are no enabled filter after a disabled one */
> > if (!(filt->flags & SAP_ETH_FILTER_ENABLED))
>
> Will any loops become better supported?
I've seen cases within loops that worked correctly, so it's not an issue
with loops.
After debugging like Julia suggested, it was indeed what Julia guessed:
some files can't be parsed correctly, at places unrelated to this.
There's nothing we can do to improve the patch.
Have a lovely day!
Alex
--
<https://www.alejandro-colomar.es>
Attachment:
signature.asc
Description: PGP signature