You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jeff Epler 9632360caa
Use a macro to compute the size of arrays at compile time (#18044)
* Add ARRAY_SIZE and CEILING utility macros

* Apply a coccinelle patch to use ARRAY_SIZE

* fix up some straggling items

* Fix 'make test:secure'

* Enhance ARRAY_SIZE macro to reject acting on pointers

The previous definition would not produce a diagnostic for
```
int *p;
size_t num_elem = ARRAY_SIZE(p)
```
but the new one will.

* explicitly get definition of ARRAY_SIZE

* Convert to ARRAY_SIZE when const is involved

The following spatch finds additional instances where the array is
const and the division is by the size of the type, not the size of
the first element:
```
@ rule5a using "empty.iso" @
type T;
const T[] E;
@@

- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)

@ rule6a using "empty.iso" @
type T;
const T[] E;
@@

- sizeof(E)/sizeof(T)
+ ARRAY_SIZE(E)
```

* New instances of ARRAY_SIZE added since initial spatch run

* Use `ARRAY_SIZE` in docs (found by grep)

* Manually use ARRAY_SIZE

hs_set is expected to be the same size as uint16_t, though it's made
of two 8-bit integers

* Just like char, sizeof(uint8_t) is guaranteed to be 1

This is at least true on any plausible system where qmk is actually used.

Per my understanding it's universally true, assuming that uint8_t exists:
https://stackoverflow.com/questions/48655310/can-i-assume-that-sizeofuint8-t-1

* Run qmk-format on core C files touched in this branch

Co-authored-by: Stefan Kerkmann <karlk90@pm.me>
3 years ago
..
process_audio.c
process_audio.h
process_auto_shift.c Fix Caps Word capitalization when used with Combos + Auto Shift. (#17549) 3 years ago
process_auto_shift.h
process_backlight.c
process_backlight.h
process_caps_word.c Fix Caps Word to treat mod-taps more consistently. (#17463) 3 years ago
process_caps_word.h [Core] Add Caps Word feature to core (#16588) 4 years ago
process_clicky.c
process_clicky.h
process_combo.c Fix Caps Word capitalization when used with Combos + Auto Shift. (#17549) 3 years ago
process_combo.h
process_dynamic_macro.c Added Wait time to sending each Keys for Dynamic Macros function (#16800) 3 years ago
process_dynamic_macro.h
process_dynamic_tapping_term.c Feature-ify Send String (#17275) 3 years ago
process_dynamic_tapping_term.h
process_grave_esc.c
process_grave_esc.h
process_haptic.c
process_haptic.h
process_joystick.c Fix check when compiling HID Joystick with digital driver (#17844) 3 years ago
process_joystick.h
process_key_lock.c
process_key_lock.h
process_key_override.c
process_key_override.h
process_leader.c Use a macro to compute the size of arrays at compile time (#18044) 3 years ago
process_leader.h
process_magic.c PoC: Swap Escape and Caps (#16336) 3 years ago
process_magic.h
process_midi.c
process_midi.h
process_music.c
process_music.h
process_printer.c
process_printer.h
process_printer_bb.c
process_programmable_button.c
process_programmable_button.h
process_rgb.c Allow for RGB actions to take place on Keydown instead of Keyup (#16886) 3 years ago
process_rgb.h
process_secure.c Enhancement and fixes of "Secure" feature (#16958) 4 years ago
process_secure.h Implement XAP 'secure' core requirements (#16843) 4 years ago
process_sequencer.c
process_sequencer.h
process_space_cadet.c Add GET_TAPPING_TERM macro to reduce duplicate code (#16681) 4 years ago
process_space_cadet.h
process_steno.c Rename postprocess_steno_user → post_process_steno_user (#17823) 3 years ago
process_steno.h Refactor steno and add `STENO_PROTOCOL = [all|txbolt|geminipr]` (#17065) 4 years ago
process_tap_dance.c tap-dance: Restructure code and document in more detail (#16394) 4 years ago
process_tap_dance.h tap-dance: Restructure code and document in more detail (#16394) 4 years ago
process_ucis.c
process_ucis.h
process_unicode.c
process_unicode.h
process_unicode_common.c Use a macro to compute the size of arrays at compile time (#18044) 3 years ago
process_unicode_common.h Added emacs as an "operating system" for input mode. (#16949) 3 years ago
process_unicodemap.c
process_unicodemap.h