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

Markus Elfring <[email protected]> Mon, 16 Mar 2026 08:18:17 +0100
Newsgroups fr.inria.cocci,org.kernel.vger.kernel-janitors,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
> Here are more false negatives that I found manually.  The semantic patch
> didn't find them.

Thanks for your clarification approach.


>                    Does anyone know how we could improve it

The corresponding knowledge is evolving.


>                                                             or why it
> didn't find them?

I suggest to refine case distinctions.
Can further test cases help to achieve a better understanding for the affected data processing?


…
> 	+++ 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?


…
> 	+++ 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?

Regards,
Markus