emacs/admin/coccinelle/arrayelts.cocci
Stefan Kangas e092aabf71 Prefer 'ARRAYELTS (x)' to 'sizeof x / sizeof *x'
* src/comp.c (emit_limple_insn):
* src/msdos.c (dos_set_keyboard, dos_rawgetc):
* src/sysdep.c (convert_speed, list_system_processes):
* src/w32fns.c (deliver_wm_chars, Fx_file_dialog):
* src/w32term.c (record_event, w32_read_socket):
Prefer 'ARRAYELTS (x)' to 'sizeof x / sizeof *x'.

* admin/coccinelle/arrayelts.cocci: New file.
2025-01-15 20:19:39 +01:00

21 lines
246 B
Text

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