emacs/admin/coccinelle/arrayelts.cocci
Paul Eggert 225876e979 ARRAYELTS → countof
C2y will standardize countof as the macro that Emacs uses the name
ARRAYELTS for.  Switch to the standard name, which is supported
by GCC 16+, by Clang 21, and by the Gnulib stdcountof-h module already
in use for compilers that do not support countof.
Also, use countof in a few places where we missed using ARRAYELTS.
* admin/coccinelle/arrayelts.cocci: Suggest countof, not ARRAYELTS.
* admin/merge-gnulib (GNULIB_MODULES): Add stdcountof-h,
as it is now a direct rather than an indirect dependency.
* exec/trace.c, src/lisp.h, src/sfnt.c: Include <stdcountof.h>.
(ARRAYELTS): Remove.  All uses replaced by countof.
* lib-src/ebrowse.c, lib-src/etags.c, lib-src/make-docfile.c:
* lib-src/seccomp-filter.c, lwlib/lwlib-Xaw.c:
Prefer <stdcountof.h> and countof to doing things by hand.
2026-05-26 21:57:20 -07:00

21 lines
238 B
Text

// Use the countof macro where possible.
@@
type T;
T[] E;
@@
- (sizeof (E) / sizeof (E[...]))
+ countof (E)
@@
type T;
T[] E;
@@
- (sizeof (E) / sizeof (T))
+ countof (E)
@@
type T;
T[] E;
@@
- (sizeof (E) / sizeof (*E))
+ countof (E)