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
..
audio In honor of king terry (#17387) 4 years ago
backlight Use a macro to compute the size of arrays at compile time (#18044) 3 years ago
bootmagic Format code according to conventions (#16322) 4 years ago
debounce Make debounce() signal changes in the cooked matrix as return value (#17554) 3 years ago
encoder/tests Asymmetric encoders, encoder tests. (#16068) 4 years ago
keymap_extras Fix DV_SCLN and DV_COLN in keymap_spanish_dvorak.h (#18043) 3 years ago
led_matrix Add led matrix support for CKLED2001 (#17643) 3 years ago
logging [Fix] Patches after printf library update (#17584) 3 years ago
painter Add ST7735 driver to Quantum Painter (#17848) 3 years ago
pointing_device [Core] Introduce pointing device specific debug messages (#17663) 3 years ago
process_keycode Use a macro to compute the size of arrays at compile time (#18044) 3 years ago
rgb_matrix Use a macro to compute the size of arrays at compile time (#18044) 3 years ago
rgblight Remove ARM pgm_read_word workaround in rgblight (#16961) 4 years ago
send_string Add missing SS_LOPT and SS_ROPT defines (#18175) 3 years ago
sequencer Format code according to conventions (#16322) 4 years ago
split_common [Core] guard RPC invocation by checking RPC info against crc checksum (#17840) 3 years ago
wear_leveling RP2040 emulated EEPROM. (#17519) 3 years ago
action.c [Bug] Add key event check to `is_tap_record` and remove `is_tap_key` (#18063) 3 years ago
action.h [Bug] Add key event check to `is_tap_record` and remove `is_tap_key` (#18063) 3 years ago
action_code.h Align TO() max layers with other keycodes (#17989) 3 years ago
action_layer.c Missed some erroneous prints. (#16597) 4 years ago
action_layer.h Make default layer size 16-bit (#15286) 4 years ago
action_tapping.c Do not enable PERMISSIVE_HOLD when TAPPING_TERM exceeds 500ms (#15674) 4 years ago
action_tapping.h Add GET_TAPPING_TERM macro to reduce duplicate code (#16681) 4 years ago
action_util.c Fix oneshot toggle logic (#16630) 4 years ago
action_util.h Format code according to conventions (#16322) 4 years ago
bitwise.c Format code according to conventions (#16322) 4 years ago
bitwise.h
caps_word.c [Core] Add Caps Word feature to core (#16588) 4 years ago
caps_word.h [Core] Add Caps Word feature to core (#16588) 4 years ago
color.c Format code according to conventions (#16322) 4 years ago
color.h fixed typo in orange HSV colors decalartion (#15976) 4 years ago
command.c [Fix] Patches after printf library update (#17584) 3 years ago
command.h Remove legacy keycode use from command (#18002) 3 years ago
config_common.h Remove deprecated KEYMAP alias (#15037) 4 years ago
crc.c
crc.h
debounce.h Make debounce() signal changes in the cooked matrix as return value (#17554) 3 years ago
deferred_exec.c Format code according to conventions (#16322) 4 years ago
deferred_exec.h Advanced deferred_exec for core-side code. (#15579) 4 years ago
digitizer.c Format code according to conventions (#16322) 4 years ago
digitizer.h
dip_switch.c Use a macro to compute the size of arrays at compile time (#18044) 3 years ago
dip_switch.h
dynamic_keymap.c Avoid OOB in dynamic_keymap_reset (#17695) 3 years ago
dynamic_keymap.h Add support for encoder mapping. (#13286) 4 years ago
dynamic_macro.h
eeconfig.c Fix oneshot toggle logic (#16630) 4 years ago
eeconfig.h Fix oneshot toggle logic (#16630) 4 years ago
encoder.c Use `TAP_CODE_DELAY` for encoder mapping by default (#18098) 3 years ago
encoder.h Use a macro to compute the size of arrays at compile time (#18044) 3 years ago
haptic.c [Feature] Add support for multiple switchs/solenoids to Haptic Feedback engine (#15657) 4 years ago
haptic.h haptic: Feature to disable it when usb port is not configured or suspended. (#12692) 4 years ago
joystick.c Joystick feature updates (#16732) 4 years ago
joystick.h Joystick: Simplify report descriptor and clean up error messages (#16926) 4 years ago
keyboard.c [Core] Process all changed keys in one scan loop, deprecate `QMK_KEYS_PER_SCAN` (#15292) 3 years ago
keyboard.h [Core] Process all changed keys in one scan loop, deprecate `QMK_KEYS_PER_SCAN` (#15292) 3 years ago
keycode.h Format code according to conventions (#16322) 4 years ago
keycode_config.c PoC: Swap Escape and Caps (#16336) 3 years ago
keycode_config.h PoC: Swap Escape and Caps (#16336) 3 years ago
keycode_legacy.h Basic keycode overhaul (#14726) 4 years ago
keymap.h [Core] Add Raspberry Pi RP2040 support (#14877) 3 years ago
keymap_common.c Align TO() max layers with other keycodes (#17989) 3 years ago
keymap_introspection.c Clean-up of `#define _ADJUST 16` instances (#18182) 3 years ago
keymap_introspection.h Add keymap wrappers for introspection into the keymap. (#17229) 4 years ago
led.c Expose the time of the last change to the LED state (#17222) 3 years ago
led.h Expose the time of the last change to the LED state (#17222) 3 years ago
led_tables.c
led_tables.h
main.c Quantum Painter (#10174) 4 years ago
matrix.c Make debounce() signal changes in the cooked matrix as return value (#17554) 3 years ago
matrix.h Custom matrix lite support for split keyboards (#14674) 4 years ago
matrix_common.c Merge remote-tracking branch 'origin/master' into develop 3 years ago
mousekey.c Merge remote-tracking branch 'origin/master' into develop 3 years ago
mousekey.h Merge remote-tracking branch 'origin/master' into develop 3 years ago
pointing_device_internal.h [Core] Introduce pointing device specific debug messages (#17663) 3 years ago
programmable_button.c Format code according to conventions (#16322) 4 years ago
programmable_button.h
quantum.c Fix QK_MAKE's reboot check (#17795) 3 years ago
quantum.h implement `tap_code16_delay` (#17748) 3 years ago
quantum_keycodes.h Added emacs as an "operating system" for input mode. (#16949) 3 years ago
quantum_keycodes_legacy.h Removes terminal from QMK. (#17258) 4 years ago
raw_hid.h Relocate protocol files within tmk_core/common/ (#14972) 4 years ago
ring_buffer.h Format code according to conventions (#16322) 4 years ago
secure.c Use a macro to compute the size of arrays at compile time (#18044) 3 years ago
secure.h Enhancement and fixes of "Secure" feature (#16958) 4 years ago
sync_timer.c Format code according to conventions (#16322) 4 years ago
sync_timer.h Relocate protocol files within tmk_core/common/ (#14972) 4 years ago
utf8.c Quantum Painter (#10174) 4 years ago
utf8.h Quantum Painter (#10174) 4 years ago
util.h Use a macro to compute the size of arrays at compile time (#18044) 3 years ago
variable_trace.c
variable_trace.h
velocikey.c Format code according to conventions (#16322) 4 years ago
velocikey.h
via.c VIA Encoder Map Support (#17734) 3 years ago
via.h VIA Encoder Map Support (#17734) 3 years ago
via_ensure_keycode.h Rename some Quantum keycodes (#15968) 4 years ago
virtser.h Relocate protocol files within tmk_core/common/ (#14972) 4 years ago
wpm.c Format code according to conventions (#16322) 4 years ago
wpm.h Fixes potential wpm sampling overflow, along with code comment fixes (#15277) 4 years ago