keychron_qmk_firmware/quantum
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>
2022-08-30 10:20:04 +02:00
..
audio In honor of king terry (#17387) 2022-06-23 02:47:15 +01:00
backlight Use a macro to compute the size of arrays at compile time (#18044) 2022-08-30 10:20:04 +02:00
bootmagic Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
debounce Make debounce() signal changes in the cooked matrix as return value (#17554) 2022-07-07 10:00:40 +02:00
encoder/tests Asymmetric encoders, encoder tests. (#16068) 2022-03-08 16:58:05 +11:00
keymap_extras Fix DV_SCLN and DV_COLN in keymap_spanish_dvorak.h (#18043) 2022-08-15 18:41:05 +01:00
led_matrix Add led matrix support for CKLED2001 (#17643) 2022-08-13 14:39:06 +01:00
logging [Fix] Patches after printf library update (#17584) 2022-07-07 14:14:09 +02:00
painter Add ST7735 driver to Quantum Painter (#17848) 2022-07-31 19:58:25 -07:00
pointing_device [Core] Introduce pointing device specific debug messages (#17663) 2022-08-29 19:16:49 +02:00
process_keycode Use a macro to compute the size of arrays at compile time (#18044) 2022-08-30 10:20:04 +02:00
rgb_matrix Use a macro to compute the size of arrays at compile time (#18044) 2022-08-30 10:20:04 +02:00
rgblight Remove ARM pgm_read_word workaround in rgblight (#16961) 2022-04-28 23:58:55 -07:00
send_string Add missing SS_LOPT and SS_ROPT defines (#18175) 2022-08-27 09:41:10 +10:00
sequencer Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
split_common [Core] guard RPC invocation by checking RPC info against crc checksum (#17840) 2022-08-06 18:46:59 +10:00
wear_leveling RP2040 emulated EEPROM. (#17519) 2022-07-02 15:18:50 +10:00
action_code.h Align TO() max layers with other keycodes (#17989) 2022-08-14 21:25:46 +10:00
action_layer.c Missed some erroneous prints. (#16597) 2022-03-10 05:43:12 +11:00
action_layer.h Make default layer size 16-bit (#15286) 2022-06-19 07:37:51 +10:00
action_tapping.c Do not enable PERMISSIVE_HOLD when TAPPING_TERM exceeds 500ms (#15674) 2022-06-24 12:40:09 +02:00
action_tapping.h Add GET_TAPPING_TERM macro to reduce duplicate code (#16681) 2022-04-16 11:24:09 -07:00
action_util.c Fix oneshot toggle logic (#16630) 2022-03-14 01:11:42 +00:00
action_util.h Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
action.c [Bug] Add key event check to is_tap_record and remove is_tap_key (#18063) 2022-08-15 16:40:51 +02:00
action.h [Bug] Add key event check to is_tap_record and remove is_tap_key (#18063) 2022-08-15 16:40:51 +02:00
bitwise.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
bitwise.h
caps_word.c [Core] Add Caps Word feature to core (#16588) 2022-05-14 16:00:32 +10:00
caps_word.h [Core] Add Caps Word feature to core (#16588) 2022-05-14 16:00:32 +10:00
color.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
color.h fixed typo in orange HSV colors decalartion (#15976) 2022-01-22 06:12:14 +00:00
command.c [Fix] Patches after printf library update (#17584) 2022-07-07 14:14:09 +02:00
command.h Remove legacy keycode use from command (#18002) 2022-08-12 03:03:36 +01:00
config_common.h
crc.c
crc.h
debounce.h Make debounce() signal changes in the cooked matrix as return value (#17554) 2022-07-07 10:00:40 +02:00
deferred_exec.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
deferred_exec.h Advanced deferred_exec for core-side code. (#15579) 2022-01-10 18:26:46 +00:00
digitizer.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
digitizer.h
dip_switch.c Use a macro to compute the size of arrays at compile time (#18044) 2022-08-30 10:20:04 +02:00
dip_switch.h
dynamic_keymap.c Avoid OOB in dynamic_keymap_reset (#17695) 2022-07-26 17:38:28 +01:00
dynamic_keymap.h Add support for encoder mapping. (#13286) 2022-03-09 19:29:00 +11:00
dynamic_macro.h
eeconfig.c Fix oneshot toggle logic (#16630) 2022-03-14 01:11:42 +00:00
eeconfig.h Fix oneshot toggle logic (#16630) 2022-03-14 01:11:42 +00:00
encoder.c Use TAP_CODE_DELAY for encoder mapping by default (#18098) 2022-08-28 21:53:08 -07:00
encoder.h Use a macro to compute the size of arrays at compile time (#18044) 2022-08-30 10:20:04 +02:00
haptic.c [Feature] Add support for multiple switchs/solenoids to Haptic Feedback engine (#15657) 2022-05-15 21:24:35 +10:00
haptic.h
joystick.c Joystick feature updates (#16732) 2022-03-26 18:38:09 +00:00
joystick.h Joystick: Simplify report descriptor and clean up error messages (#16926) 2022-04-26 08:54:34 +10:00
keyboard.c [Core] Process all changed keys in one scan loop, deprecate QMK_KEYS_PER_SCAN (#15292) 2022-08-06 20:51:13 +10:00
keyboard.h [Core] Process all changed keys in one scan loop, deprecate QMK_KEYS_PER_SCAN (#15292) 2022-08-06 20:51:13 +10:00
keycode_config.c PoC: Swap Escape and Caps (#16336) 2022-07-02 22:08:48 +10:00
keycode_config.h PoC: Swap Escape and Caps (#16336) 2022-07-02 22:08:48 +10:00
keycode_legacy.h
keycode.h Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
keymap_common.c Align TO() max layers with other keycodes (#17989) 2022-08-14 21:25:46 +10:00
keymap_introspection.c Clean-up of #define _ADJUST 16 instances (#18182) 2022-08-27 23:13:44 -07:00
keymap_introspection.h Add keymap wrappers for introspection into the keymap. (#17229) 2022-06-05 10:26:02 +10:00
keymap.h [Core] Add Raspberry Pi RP2040 support (#14877) 2022-06-30 13:19:27 +02:00
led_tables.c
led_tables.h
led.c Expose the time of the last change to the LED state (#17222) 2022-07-02 21:57:05 +10:00
led.h Expose the time of the last change to the LED state (#17222) 2022-07-02 21:57:05 +10:00
main.c Quantum Painter (#10174) 2022-04-13 18:00:18 +10:00
matrix_common.c Merge remote-tracking branch 'origin/master' into develop 2022-08-07 19:33:39 +00:00
matrix.c Make debounce() signal changes in the cooked matrix as return value (#17554) 2022-07-07 10:00:40 +02:00
matrix.h Custom matrix lite support for split keyboards (#14674) 2021-12-27 21:03:40 +11:00
mousekey.c Merge remote-tracking branch 'origin/master' into develop 2022-06-29 08:17:56 +00:00
mousekey.h Merge remote-tracking branch 'origin/master' into develop 2022-06-29 08:17:56 +00:00
pointing_device_internal.h [Core] Introduce pointing device specific debug messages (#17663) 2022-08-29 19:16:49 +02:00
programmable_button.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
programmable_button.h
quantum_keycodes_legacy.h Removes terminal from QMK. (#17258) 2022-05-30 22:38:08 -07:00
quantum_keycodes.h Added emacs as an "operating system" for input mode. (#16949) 2022-08-14 20:24:52 +01:00
quantum.c Fix QK_MAKE's reboot check (#17795) 2022-07-25 23:06:26 +01:00
quantum.h implement tap_code16_delay (#17748) 2022-07-23 19:21:20 +01:00
raw_hid.h
ring_buffer.h Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
secure.c Use a macro to compute the size of arrays at compile time (#18044) 2022-08-30 10:20:04 +02:00
secure.h Enhancement and fixes of "Secure" feature (#16958) 2022-05-14 23:07:08 +01:00
sync_timer.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
sync_timer.h
utf8.c Quantum Painter (#10174) 2022-04-13 18:00:18 +10:00
utf8.h Quantum Painter (#10174) 2022-04-13 18:00:18 +10:00
util.h Use a macro to compute the size of arrays at compile time (#18044) 2022-08-30 10:20:04 +02:00
variable_trace.c
variable_trace.h
velocikey.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
velocikey.h
via_ensure_keycode.h Rename some Quantum keycodes (#15968) 2022-01-22 03:34:15 +00:00
via.c VIA Encoder Map Support (#17734) 2022-07-21 09:53:42 +10:00
via.h VIA Encoder Map Support (#17734) 2022-07-21 09:53:42 +10:00
virtser.h
wpm.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
wpm.h Fixes potential wpm sampling overflow, along with code comment fixes (#15277) 2021-12-27 11:52:56 +11:00