summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2022-08-30 03:20:04 -0500
committerGitHub <noreply@github.com>2022-08-30 10:20:04 +0200
commit9632360caa5e6511b0ec13cb4c55eb64408232b5 (patch)
treedb4e0d47fb8d4918a3f7361647a4afca13da23e0
parent2c5aa98143fc1bb76299033042b374b2ce148d93 (diff)
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>
-rw-r--r--docs/feature_combo.md2
-rw-r--r--drivers/haptic/solenoid.c5
-rw-r--r--drivers/sensors/pmw33xx_common.c6
-rw-r--r--keyboards/25keys/zinc/keymaps/ginjake/keymap.c2
-rwxr-xr-xkeyboards/acheron/shark/beta/keymaps/gondolindrim/keymap.c2
-rw-r--r--keyboards/adafruit/macropad/lib/ssd1306_sh1106.c2
-rw-r--r--keyboards/crkbd/keymaps/gotham/oled.c2
-rw-r--r--keyboards/crkbd/keymaps/thunderbird2086/oled.c2
-rw-r--r--keyboards/dm9records/plaid/keymaps/brickbots/keymap.c2
-rw-r--r--keyboards/dm9records/plaid/keymaps/default/keymap.c2
-rw-r--r--keyboards/dm9records/plaid/keymaps/stephen-huan/keymap.c2
-rw-r--r--keyboards/dmqdesign/spin/keymaps/spidey3_pad/keymap.c2
-rwxr-xr-xkeyboards/evolv/keymaps/gondolindrim/keymap.c2
-rw-r--r--keyboards/gboards/butterstick/keymaps/default/keymap.c2
-rw-r--r--keyboards/gboards/butterstick/sten.c2
-rw-r--r--keyboards/gboards/engine/keymap_engine.h10
-rw-r--r--keyboards/gboards/g/keymap_engine.h10
-rw-r--r--keyboards/gboards/georgi/keymaps/colemak-dh/keymap.c4
-rw-r--r--keyboards/gboards/georgi/keymaps/default-flipped/keymap.c2
-rw-r--r--keyboards/gboards/georgi/keymaps/default/keymap.c2
-rw-r--r--keyboards/gboards/georgi/keymaps/minimal/keymap.c2
-rw-r--r--keyboards/gboards/georgi/keymaps/norman/keymap.c2
-rw-r--r--keyboards/gboards/georgi/sten.c2
-rw-r--r--keyboards/gmmk/pro/rev1/ansi/keymaps/cedrikl/keymap.c21
-rw-r--r--keyboards/gmmk/pro/rev1/ansi/keymaps/gourdo1/keymap.c2
-rw-r--r--keyboards/gmmk/pro/rev1/ansi/keymaps/paddlegame/keymap.c12
-rw-r--r--keyboards/gmmk/pro/rev1/iso/keymaps/chofstede/keymap.c4
-rw-r--r--keyboards/gmmk/pro/rev1/iso/keymaps/gourdo1/keymap.c2
-rw-r--r--keyboards/gopolar/gg86/keymaps/horrortroll/keymap_stuff.h2
-rw-r--r--keyboards/gopolar/gg86/lib/wave.h2
-rw-r--r--keyboards/handwired/lagrange/keymaps/dpapavas/keymap.c4
-rw-r--r--keyboards/handwired/myskeeb/oled.c2
-rw-r--r--keyboards/handwired/nicekey/keymaps/default/keymap.c2
-rw-r--r--keyboards/handwired/onekey/keymaps/chibios_waiting_test/keymap.c4
-rw-r--r--keyboards/handwired/promethium/keymaps/default/keymap.c2
-rw-r--r--keyboards/handwired/promethium/keymaps/priyadi/keymap.c2
-rw-r--r--keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c2
-rw-r--r--keyboards/horrortroll/handwired_k552/keymaps/default/keymap_stuff.h2
-rw-r--r--keyboards/horrortroll/handwired_k552/keymaps/via/keymap_stuff.h2
-rw-r--r--keyboards/horrortroll/handwired_k552/lib/wave.c2
-rw-r--r--keyboards/lfkeyboards/lfkpad/keymaps/pascalpfeil/keymap.c2
-rw-r--r--keyboards/massdrop/ctrl/keymaps/responsive_pattern/keymap.c3
-rw-r--r--keyboards/mechwild/mercutio/keymaps/fearless_spiff/keymap.c2
-rw-r--r--keyboards/mechwild/mercutio/keymaps/fearless_spiff_en/keymap.c2
-rwxr-xr-xkeyboards/mechwild/mercutio/keymaps/jonavin/keymap.c2
-rw-r--r--keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c2
-rw-r--r--keyboards/mechwild/puckbuddy/puckbuddy.c2
-rw-r--r--keyboards/mitosis/keymaps/datagrok/keymap.c2
-rw-r--r--keyboards/mwstudio/mw65_rgb/keymaps/horrortroll/keymap_stuff.h2
-rw-r--r--keyboards/mxss/keymaps/default/keymap.c2
-rw-r--r--keyboards/mxss/mxss_frontled.c2
-rw-r--r--keyboards/mxss/templates/keymap.c2
-rw-r--r--keyboards/ploopyco/mouse/mouse.c4
-rw-r--r--keyboards/ploopyco/trackball/trackball.c4
-rw-r--r--keyboards/ploopyco/trackball_mini/trackball_mini.c4
-rw-r--r--keyboards/ploopyco/trackball_nano/trackball_nano.c4
-rw-r--r--keyboards/rgbkb/pan/pan.c2
-rw-r--r--keyboards/rgbkb/sol/keymaps/default/keymap.c2
-rw-r--r--keyboards/rgbkb/sol/keymaps/xyverz/keymap.c2
-rw-r--r--keyboards/rocketboard_16/keycode_lookup.c2
-rw-r--r--keyboards/torn/bongocat.c2
-rw-r--r--keyboards/tzarc/djinn/djinn_portscan_matrix.c8
-rw-r--r--keyboards/ymdk/melody96/keymaps/konstantin/keymap.c2
-rw-r--r--lib/usbhost/USB_Host_Shield_2.0/SPP.cpp2
-rw-r--r--lib/usbhost/USB_Host_Shield_2.0/examples/Bluetooth/PS3Multi/PS3Multi.ino2
-rw-r--r--lib/usbhost/USB_Host_Shield_2.0/examples/Bluetooth/WiiMulti/WiiMulti.ino2
-rw-r--r--lib/usbhost/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.h2
-rw-r--r--lib/usbhost/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h2
-rw-r--r--platforms/chibios/drivers/ws2812_spi.c6
-rw-r--r--quantum/backlight/backlight_driver_common.c2
-rw-r--r--quantum/backlight/backlight_software.c2
-rw-r--r--quantum/dip_switch.c4
-rw-r--r--quantum/encoder.h8
-rw-r--r--quantum/process_keycode/process_leader.c2
-rw-r--r--quantum/process_keycode/process_unicode_common.c2
-rw-r--r--quantum/rgb_matrix/rgb_matrix_drivers.c2
-rw-r--r--quantum/secure.c3
-rw-r--r--quantum/util.h49
-rw-r--r--tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c2
-rw-r--r--users/brandonschlack/rgb_bs.c2
-rw-r--r--users/curry/oled.c2
-rw-r--r--users/davidkristoffersen/util/functions.c8
-rw-r--r--users/davidkristoffersen/util/functions.h2
-rw-r--r--users/drashna/keyrecords/tap_dance.md2
-rw-r--r--users/drashna/keyrecords/tap_dances.c2
-rw-r--r--users/drashna/keyrecords/unicode.c2
-rw-r--r--users/drashna/oled/oled_stuff.c2
-rw-r--r--users/gourdo1/gourdo1.h3
-rw-r--r--users/jonavin/jonavin.h3
-rw-r--r--users/spidey3/layer_rgb.c2
-rw-r--r--users/uqs/uqs.c20
91 files changed, 178 insertions, 165 deletions
diff --git a/docs/feature_combo.md b/docs/feature_combo.md
index 42d965509b..bb0b5d7aa0 100644
--- a/docs/feature_combo.md
+++ b/docs/feature_combo.md
@@ -255,7 +255,7 @@ bool combo_should_trigger(uint16_t combo_index, combo_t *combo, uint16_t keycode
255``` 255```
256 256
257## Variable Length Combos 257## Variable Length Combos
258If you leave `COMBO_COUNT` undefined in `config.h`, it allows you to programmatically declare the size of the Combo data structure and avoid updating `COMBO_COUNT`. Instead a variable called `COMBO_LEN` has to be set. It can be set with something similar to the following in `keymap.c`: `uint16_t COMBO_LEN = sizeof(key_combos) / sizeof(key_combos[0]);` or by adding `COMBO_LENGTH` as the *last* entry in the combo enum and then `uint16_t COMBO_LEN = COMBO_LENGTH;` as such: 258If you leave `COMBO_COUNT` undefined in `config.h`, it allows you to programmatically declare the size of the Combo data structure and avoid updating `COMBO_COUNT`. Instead a variable called `COMBO_LEN` has to be set. It can be set with something similar to the following in `keymap.c`: `uint16_t COMBO_LEN = ARRAY_SIZE(key_combos);` or by adding `COMBO_LENGTH` as the *last* entry in the combo enum and then `uint16_t COMBO_LEN = COMBO_LENGTH;` as such:
259```c 259```c
260enum myCombos { 260enum myCombos {
261 ..., 261 ...,
diff --git a/drivers/haptic/solenoid.c b/drivers/haptic/solenoid.c
index 637a77da3d..4e43903255 100644
--- a/drivers/haptic/solenoid.c
+++ b/drivers/haptic/solenoid.c
@@ -20,11 +20,12 @@
20#include "haptic.h" 20#include "haptic.h"
21#include "gpio.h" 21#include "gpio.h"
22#include "usb_device_state.h" 22#include "usb_device_state.h"
23#include "util.h"
23#include <stdlib.h> 24#include <stdlib.h>
24 25
25uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL; 26uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL;
26static pin_t solenoid_pads[] = SOLENOID_PINS; 27static pin_t solenoid_pads[] = SOLENOID_PINS;
27#define NUMBER_OF_SOLENOIDS (sizeof(solenoid_pads) / sizeof(pin_t)) 28#define NUMBER_OF_SOLENOIDS ARRAY_SIZE(solenoid_pads)
28bool solenoid_on[NUMBER_OF_SOLENOIDS] = {false}; 29bool solenoid_on[NUMBER_OF_SOLENOIDS] = {false};
29bool solenoid_buzzing[NUMBER_OF_SOLENOIDS] = {false}; 30bool solenoid_buzzing[NUMBER_OF_SOLENOIDS] = {false};
30uint16_t solenoid_start[NUMBER_OF_SOLENOIDS] = {0}; 31uint16_t solenoid_start[NUMBER_OF_SOLENOIDS] = {0};
@@ -147,7 +148,7 @@ void solenoid_check(void) {
147void solenoid_setup(void) { 148void solenoid_setup(void) {
148#ifdef SOLENOID_PINS_ACTIVE_STATE 149#ifdef SOLENOID_PINS_ACTIVE_STATE
149 bool state_temp[] = SOLENOID_PINS_ACTIVE_STATE; 150 bool state_temp[] = SOLENOID_PINS_ACTIVE_STATE;
150 uint8_t bound_check = (sizeof(state_temp) / sizeof(bool)); 151 uint8_t bound_check = ARRAY_SIZE(state_temp);
151#endif 152#endif
152 153
153 for (uint8_t i = 0; i < NUMBER_OF_SOLENOIDS; i++) { 154 for (uint8_t i = 0; i < NUMBER_OF_SOLENOIDS; i++) {
diff --git a/drivers/sensors/pmw33xx_common.c b/drivers/sensors/pmw33xx_common.c
index 4993cc2d34..b8d4e532ca 100644
--- a/drivers/sensors/pmw33xx_common.c
+++ b/drivers/sensors/pmw33xx_common.c
@@ -17,10 +17,10 @@
17extern const uint8_t pmw33xx_firmware_data[PMW33XX_FIRMWARE_LENGTH] PROGMEM; 17extern const uint8_t pmw33xx_firmware_data[PMW33XX_FIRMWARE_LENGTH] PROGMEM;
18extern const uint8_t pmw33xx_firmware_signature[3] PROGMEM; 18extern const uint8_t pmw33xx_firmware_signature[3] PROGMEM;
19 19
20static const pin_t cs_pins[] = PMW33XX_CS_PINS; 20static const pin_t cs_pins[] = PMW33XX_CS_PINS;
21static bool in_burst[sizeof(cs_pins) / sizeof(pin_t)] = {0}; 21static bool in_burst[ARRAY_SIZE(cs_pins)] = {0};
22 22
23const size_t pmw33xx_number_of_sensors = sizeof(cs_pins) / sizeof(pin_t); 23const size_t pmw33xx_number_of_sensors = ARRAY_SIZE(cs_pins);
24 24
25bool __attribute__((cold)) pmw33xx_upload_firmware(uint8_t sensor); 25bool __attribute__((cold)) pmw33xx_upload_firmware(uint8_t sensor);
26bool __attribute__((cold)) pmw33xx_check_signature(uint8_t sensor); 26bool __attribute__((cold)) pmw33xx_check_signature(uint8_t sensor);
diff --git a/keyboards/25keys/zinc/keymaps/ginjake/keymap.c b/keyboards/25keys/zinc/keymaps/ginjake/keymap.c
index 93dfc590e9..26190a2a91 100644
--- a/keyboards/25keys/zinc/keymaps/ginjake/keymap.c
+++ b/keyboards/25keys/zinc/keymaps/ginjake/keymap.c
@@ -333,7 +333,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
333 aqours_num++; 333 aqours_num++;
334 aqours_next_color_timer_count = 0; 334 aqours_next_color_timer_count = 0;
335 target_col = 0; 335 target_col = 0;
336 if (aqours_num == sizeof(aqours_h) / sizeof(int)) { 336 if (aqours_num == ARRAY_SIZE(aqours_h)) {
337 aqours_num = 0; 337 aqours_num = 0;
338 } 338 }
339 } 339 }
diff --git a/keyboards/acheron/shark/beta/keymaps/gondolindrim/keymap.c b/keyboards/acheron/shark/beta/keymaps/gondolindrim/keymap.c
index cae98411d6..fd7f556b56 100755
--- a/keyboards/acheron/shark/beta/keymaps/gondolindrim/keymap.c
+++ b/keyboards/acheron/shark/beta/keymaps/gondolindrim/keymap.c
@@ -94,7 +94,7 @@ encoder_mode_t encoder_modes[] = {
94 // Insert your custom encoder mode here 94 // Insert your custom encoder mode here
95}; 95};
96 96
97#define NUM_ENCODER_MODES (sizeof(encoder_modes)/sizeof(encoder_modes[0])) 97#define NUM_ENCODER_MODES ARRAY_SIZE(encoder_modes)
98 98
99// This counter is used to track what encoder mode is being used at a certain time 99// This counter is used to track what encoder mode is being used at a certain time
100int encoder_mode_count = 0; 100int encoder_mode_count = 0;
diff --git a/keyboards/adafruit/macropad/lib/ssd1306_sh1106.c b/keyboards/adafruit/macropad/lib/ssd1306_sh1106.c
index dc1289fdb1..1b05809640 100644
--- a/keyboards/adafruit/macropad/lib/ssd1306_sh1106.c
+++ b/keyboards/adafruit/macropad/lib/ssd1306_sh1106.c
@@ -94,8 +94,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
94 94
95#define OLED_ALL_BLOCKS_MASK (((((OLED_BLOCK_TYPE)1 << (OLED_BLOCK_COUNT - 1)) - 1) << 1) | 1) 95#define OLED_ALL_BLOCKS_MASK (((((OLED_BLOCK_TYPE)1 << (OLED_BLOCK_COUNT - 1)) - 1) << 1) | 1)
96 96
97#define ARRAY_SIZE(arr) sizeof(arr)/sizeof(arr[0])
98
99// spi defines 97// spi defines
100#define OLED_STATUS_SUCCESS SPI_STATUS_SUCCESS 98#define OLED_STATUS_SUCCESS SPI_STATUS_SUCCESS
101 99
diff --git a/keyboards/crkbd/keymaps/gotham/oled.c b/keyboards/crkbd/keymaps/gotham/oled.c
index c4ac5e736c..c285a37c5b 100644
--- a/keyboards/crkbd/keymaps/gotham/oled.c
+++ b/keyboards/crkbd/keymaps/gotham/oled.c
@@ -176,7 +176,7 @@ void add_keylog(uint16_t keycode) {
176 keylog_str[i] = keylog_str[i - 1]; 176 keylog_str[i] = keylog_str[i - 1];
177 } 177 }
178 178
179 if (keycode < (sizeof(code_to_name) / sizeof(char))) { 179 if (keycode < ARRAY_SIZE(code_to_name)) {
180 keylog_str[0] = pgm_read_byte(&code_to_name[keycode]); 180 keylog_str[0] = pgm_read_byte(&code_to_name[keycode]);
181 } 181 }
182} 182}
diff --git a/keyboards/crkbd/keymaps/thunderbird2086/oled.c b/keyboards/crkbd/keymaps/thunderbird2086/oled.c
index bee9bc26de..108f3e0cdd 100644
--- a/keyboards/crkbd/keymaps/thunderbird2086/oled.c
+++ b/keyboards/crkbd/keymaps/thunderbird2086/oled.c
@@ -189,7 +189,7 @@ void add_keylog(uint16_t keycode) {
189 keylog_str[i] = keylog_str[i - 1]; 189 keylog_str[i] = keylog_str[i - 1];
190 } 190 }
191 191
192 if (keycode < (sizeof(code_to_name) / sizeof(char))) { 192 if (keycode < ARRAY_SIZE(code_to_name)) {
193 keylog_str[0] = pgm_read_byte(&code_to_name[keycode]); 193 keylog_str[0] = pgm_read_byte(&code_to_name[keycode]);
194 } 194 }
195} 195}
diff --git a/keyboards/dm9records/plaid/keymaps/brickbots/keymap.c b/keyboards/dm9records/plaid/keymaps/brickbots/keymap.c
index 819b76e739..0442c930fe 100644
--- a/keyboards/dm9records/plaid/keymaps/brickbots/keymap.c
+++ b/keyboards/dm9records/plaid/keymaps/brickbots/keymap.c
@@ -242,7 +242,7 @@ layer_state_t layer_state_set_user(layer_state_t state) {
242void led_keypress_update(uint8_t led, uint8_t led_mode, uint16_t keycode, keyrecord_t *record) { 242void led_keypress_update(uint8_t led, uint8_t led_mode, uint16_t keycode, keyrecord_t *record) {
243 switch (led_mode) { 243 switch (led_mode) {
244 case LEDMODE_MODS: 244 case LEDMODE_MODS:
245 for (int i=0;i<sizeof(modifiers) / sizeof(modifiers[0]);i++) { 245 for (int i=0;i<ARRAY_SIZE(modifiers);i++) {
246 if(keycode==modifiers[i]) { 246 if(keycode==modifiers[i]) {
247 if (record->event.pressed) { 247 if (record->event.pressed) {
248 writePinHigh(led); 248 writePinHigh(led);
diff --git a/keyboards/dm9records/plaid/keymaps/default/keymap.c b/keyboards/dm9records/plaid/keymaps/default/keymap.c
index d96c250609..aa0bd8b093 100644
--- a/keyboards/dm9records/plaid/keymaps/default/keymap.c
+++ b/keyboards/dm9records/plaid/keymaps/default/keymap.c
@@ -245,7 +245,7 @@ layer_state_t layer_state_set_user(layer_state_t state) {
245void led_keypress_update(uint8_t led, uint8_t led_mode, uint16_t keycode, keyrecord_t *record) { 245void led_keypress_update(uint8_t led, uint8_t led_mode, uint16_t keycode, keyrecord_t *record) {
246 switch (led_mode) { 246 switch (led_mode) {
247 case LEDMODE_MODS: 247 case LEDMODE_MODS:
248 for (int i=0;i<sizeof(modifiers) / sizeof(modifiers[0]);i++) { 248 for (int i=0;i<ARRAY_SIZE(modifiers);i++) {
249 if(keycode==modifiers[i]) { 249 if(keycode==modifiers[i]) {
250 if (record->event.pressed) { 250 if (record->event.pressed) {
251 writePinHigh(led); 251 writePinHigh(led);
diff --git a/keyboards/dm9records/plaid/keymaps/stephen-huan/keymap.c b/keyboards/dm9records/plaid/keymaps/stephen-huan/keymap.c
index 354599f340..9a0e89bd89 100644
--- a/keyboards/dm9records/plaid/keymaps/stephen-huan/keymap.c
+++ b/keyboards/dm9records/plaid/keymaps/stephen-huan/keymap.c
@@ -184,7 +184,7 @@ layer_state_t layer_state_set_user(layer_state_t state) {
184void led_keypress_update(uint8_t led, uint8_t led_mode, uint16_t keycode, keyrecord_t *record) { 184void led_keypress_update(uint8_t led, uint8_t led_mode, uint16_t keycode, keyrecord_t *record) {
185 switch (led_mode) { 185 switch (led_mode) {
186 case LEDMODE_MODS: 186 case LEDMODE_MODS:
187 for (int i=0;i<sizeof(modifiers) / sizeof(modifiers[0]);i++) { 187 for (int i=0;i<ARRAY_SIZE(modifiers);i++) {
188 if(keycode==modifiers[i]) { 188 if(keycode==modifiers[i]) {
189 if (record->event.pressed) { 189 if (record->event.pressed) {
190 writePinHigh(led); 190 writePinHigh(led);
diff --git a/keyboards/dmqdesign/spin/keymaps/spidey3_pad/keymap.c b/keyboards/dmqdesign/spin/keymaps/spidey3_pad/keymap.c
index 8c9af7202b..77534b9a75 100644
--- a/keyboards/dmqdesign/spin/keymaps/spidey3_pad/keymap.c
+++ b/keyboards/dmqdesign/spin/keymaps/spidey3_pad/keymap.c
@@ -111,7 +111,7 @@ const rgblight_segment_t *const PROGMEM _rgb_layers[] = {
111}; 111};
112// clang-format off 112// clang-format off
113 113
114const uint8_t PROGMEM _n_rgb_layers = sizeof(_rgb_layers) / sizeof(_rgb_layers[0]) - 1; 114const uint8_t PROGMEM _n_rgb_layers = ARRAY_SIZE(_rgb_layers) - 1;
115 115
116void clear_rgb_layers(void) { 116void clear_rgb_layers(void) {
117 dprint("clear_rgb_layers()\n"); 117 dprint("clear_rgb_layers()\n");
diff --git a/keyboards/evolv/keymaps/gondolindrim/keymap.c b/keyboards/evolv/keymaps/gondolindrim/keymap.c
index 3ab66bd056..bf0944fbd1 100755
--- a/keyboards/evolv/keymaps/gondolindrim/keymap.c
+++ b/keyboards/evolv/keymaps/gondolindrim/keymap.c
@@ -129,7 +129,7 @@ const encoder_mode_t encoder_modes[] = {
129 // Insert your custom encoder mode here 129 // Insert your custom encoder mode here
130}; 130};
131 131
132#define NUM_ENCODER_MODES (sizeof(encoder_modes)/sizeof(encoder_modes[0])) // DO NOT CHANGE THIS. NUM_ENCODER_MODES calculates how many modes there are. 132#define NUM_ENCODER_MODES ARRAY_SIZE(encoder_modes) // DO NOT CHANGE THIS. NUM_ENCODER_MODES calculates how many modes there are.
133 133
134// This counter is used to track what encoder mode is being used at a certain time 134// This counter is used to track what encoder mode is being used at a certain time
135int encoder_mode_count = 0; 135int encoder_mode_count = 0;
diff --git a/keyboards/gboards/butterstick/keymaps/default/keymap.c b/keyboards/gboards/butterstick/keymaps/default/keymap.c
index 749e9ba071..d0c6af65df 100644
--- a/keyboards/gboards/butterstick/keymaps/default/keymap.c
+++ b/keyboards/gboards/butterstick/keymaps/default/keymap.c
@@ -180,4 +180,4 @@ uint32_t processQwerty(bool lookup) {
180} 180}
181 181
182// Don't fuck with this, thanks. 182// Don't fuck with this, thanks.
183size_t keymapsCount = sizeof(keymaps)/sizeof(keymaps[0]); 183size_t keymapsCount = ARRAY_SIZE(keymaps);
diff --git a/keyboards/gboards/butterstick/sten.c b/keyboards/gboards/butterstick/sten.c
index 197abaf92f..8820127848 100644
--- a/keyboards/gboards/butterstick/sten.c
+++ b/keyboards/gboards/butterstick/sten.c
@@ -21,7 +21,7 @@ uint32_t tChord = 0; // Protects state of cChord
21 21
22#ifndef STENOLAYERS 22#ifndef STENOLAYERS
23uint32_t stenoLayers[] = { PWR }; 23uint32_t stenoLayers[] = { PWR };
24size_t stenoLayerCount = sizeof(stenoLayers)/sizeof(stenoLayers[0]); 24size_t stenoLayerCount = ARRAY_SIZE(stenoLayers);
25#endif 25#endif
26 26
27// Mode state 27// Mode state
diff --git a/keyboards/gboards/engine/keymap_engine.h b/keyboards/gboards/engine/keymap_engine.h
index c8a42a052b..599c1ca3e4 100644
--- a/keyboards/gboards/engine/keymap_engine.h
+++ b/keyboards/gboards/engine/keymap_engine.h
@@ -114,8 +114,8 @@ void testCollisions(void) {
114#include "dicts.def" 114#include "dicts.def"
115 115
116// Get size data back into the engine 116// Get size data back into the engine
117size_t funcsLen = sizeof(funDict) / sizeof(funDict[0]); 117size_t funcsLen = ARRAY_SIZE(funDict);
118size_t stringLen = sizeof(strDict) / sizeof(strDict[0]); 118size_t stringLen = ARRAY_SIZE(strDict);
119size_t keyLen = sizeof(keyDict) / sizeof(keyDict[0]); 119size_t keyLen = ARRAY_SIZE(keyDict);
120size_t comboLen = sizeof(cmbDict) / sizeof(cmbDict[0]); 120size_t comboLen = ARRAY_SIZE(cmbDict);
121size_t specialLen = sizeof(spcDict) / sizeof(spcDict[0]); 121size_t specialLen = ARRAY_SIZE(spcDict);
diff --git a/keyboards/gboards/g/keymap_engine.h b/keyboards/gboards/g/keymap_engine.h
index 93a4423340..055b5941e4 100644
--- a/keyboards/gboards/g/keymap_engine.h
+++ b/keyboards/gboards/g/keymap_engine.h
@@ -115,8 +115,8 @@ void testCollisions(void) {
115#include "dicts.def" 115#include "dicts.def"
116 116
117// Get size data back into the engine 117// Get size data back into the engine
118size_t funcsLen = sizeof(funDict) / sizeof(funDict[0]); 118size_t funcsLen = ARRAY_SIZE(funDict);
119size_t stringLen = sizeof(strDict) / sizeof(strDict[0]); 119size_t stringLen = ARRAY_SIZE(strDict);
120size_t keyLen = sizeof(keyDict) / sizeof(keyDict[0]); 120size_t keyLen = ARRAY_SIZE(keyDict);
121size_t comboLen = sizeof(cmbDict) / sizeof(cmbDict[0]); 121size_t comboLen = ARRAY_SIZE(cmbDict);
122size_t specialLen = sizeof(spcDict) / sizeof(spcDict[0]); 122size_t specialLen = ARRAY_SIZE(spcDict);
diff --git a/keyboards/gboards/georgi/keymaps/colemak-dh/keymap.c b/keyboards/gboards/georgi/keymaps/colemak-dh/keymap.c
index 29b35f6abd..af7edc2a9b 100644
--- a/keyboards/gboards/georgi/keymaps/colemak-dh/keymap.c
+++ b/keyboards/gboards/georgi/keymaps/colemak-dh/keymap.c
@@ -302,5 +302,5 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
302}; 302};
303 303
304// Don't fuck with this, thanks. 304// Don't fuck with this, thanks.
305size_t keymapsCount = sizeof(keymaps)/sizeof(keymaps[0]); 305size_t keymapsCount = ARRAY_SIZE(keymaps);
306size_t stenoLayerCount = sizeof(stenoLayers)/sizeof(stenoLayers[0]); 306size_t stenoLayerCount = ARRAY_SIZE(stenoLayers);
diff --git a/keyboards/gboards/georgi/keymaps/default-flipped/keymap.c b/keyboards/gboards/georgi/keymaps/default-flipped/keymap.c
index 09243f2a24..a3324b11cd 100644
--- a/keyboards/gboards/georgi/keymaps/default-flipped/keymap.c
+++ b/keyboards/gboards/georgi/keymaps/default-flipped/keymap.c
@@ -234,4 +234,4 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
234}; 234};
235 235
236// Don't fuck with this, thanks. 236// Don't fuck with this, thanks.
237size_t keymapsCount = sizeof(keymaps)/sizeof(keymaps[0]); 237size_t keymapsCount = ARRAY_SIZE(keymaps);
diff --git a/keyboards/gboards/georgi/keymaps/default/keymap.c b/keyboards/gboards/georgi/keymaps/default/keymap.c
index 93c551af27..78964dc840 100644
--- a/keyboards/gboards/georgi/keymaps/default/keymap.c
+++ b/keyboards/gboards/georgi/keymaps/default/keymap.c
@@ -244,4 +244,4 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
244}; 244};
245 245
246// Don't fuck with this, thanks. 246// Don't fuck with this, thanks.
247size_t keymapsCount = sizeof(keymaps)/sizeof(keymaps[0]); 247size_t keymapsCount = ARRAY_SIZE(keymaps);
diff --git a/keyboards/gboards/georgi/keymaps/minimal/keymap.c b/keyboards/gboards/georgi/keymaps/minimal/keymap.c
index e9294c5cc8..c4e78033bd 100644
--- a/keyboards/gboards/georgi/keymaps/minimal/keymap.c
+++ b/keyboards/gboards/georgi/keymaps/minimal/keymap.c
@@ -219,4 +219,4 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
219 ) 219 )
220}; 220};
221// Don't fuck with this, thanks. 221// Don't fuck with this, thanks.
222size_t keymapsCount = sizeof(keymaps)/sizeof(keymaps[0]); 222size_t keymapsCount = ARRAY_SIZE(keymaps);
diff --git a/keyboards/gboards/georgi/keymaps/norman/keymap.c b/keyboards/gboards/georgi/keymaps/norman/keymap.c
index 4591aab22f..870e460e2c 100644
--- a/keyboards/gboards/georgi/keymaps/norman/keymap.c
+++ b/keyboards/gboards/georgi/keymaps/norman/keymap.c
@@ -263,4 +263,4 @@ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGDN, KC_LEFT, KC
263 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS) 263 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
264}; 264};
265// Don't fuck with this, thanks. 265// Don't fuck with this, thanks.
266size_t keymapsCount = sizeof(keymaps)/sizeof(keymaps[0]); 266size_t keymapsCount = ARRAY_SIZE(keymaps);
diff --git a/keyboards/gboards/georgi/sten.c b/keyboards/gboards/georgi/sten.c
index c7469b6394..bd96dee758 100644
--- a/keyboards/gboards/georgi/sten.c
+++ b/keyboards/gboards/georgi/sten.c
@@ -21,7 +21,7 @@ uint32_t tChord = 0; // Protects state of cChord
21 21
22#ifndef STENOLAYERS 22#ifndef STENOLAYERS
23uint32_t stenoLayers[] = { PWR }; 23uint32_t stenoLayers[] = { PWR };
24size_t stenoLayerCount = sizeof(stenoLayers)/sizeof(stenoLayers[0]); 24size_t stenoLayerCount = ARRAY_SIZE(stenoLayers);
25#endif 25#endif
26 26
27// Mode state 27// Mode state
diff --git a/keyboards/gmmk/pro/rev1/ansi/keymaps/cedrikl/keymap.c b/keyboards/gmmk/pro/rev1/ansi/keymaps/cedrikl/keymap.c
index 09f8aa147a..3aa3fd828e 100644
--- a/keyboards/gmmk/pro/rev1/ansi/keymaps/cedrikl/keymap.c
+++ b/keyboards/gmmk/pro/rev1/ansi/keymaps/cedrikl/keymap.c
@@ -107,16 +107,22 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
107 107
108 // Capslock, Scroll lock and Numlock indicator on Left side lights. 108 // Capslock, Scroll lock and Numlock indicator on Left side lights.
109 void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { 109 void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
110 loop_colorset(LED_REGION_A, (sizeof(LED_REGION_A) / sizeof(LED_REGION_A[0])), hsv_cl_blue); 110 loop_colorset(LED_REGION_A, ARRAY_SIZE(LED_REGION_A),
111 loop_colorset(LED_REGION_B, (sizeof(LED_REGION_B) / sizeof(LED_REGION_B[0])), hsv_cl_purple); 111 hsv_cl_blue);
112 loop_colorset(LED_REGION_L_SIDE, (sizeof(LED_REGION_L_SIDE) / sizeof(LED_REGION_L_SIDE[0])), hsv_cl_purple); 112 loop_colorset(LED_REGION_B, ARRAY_SIZE(LED_REGION_B),
113 loop_colorset(LED_REGION_R_SIDE, (sizeof(LED_REGION_R_SIDE) / sizeof(LED_REGION_R_SIDE[0])), hsv_cl_purple); 113 hsv_cl_purple);
114 loop_colorset(LED_REGION_L_SIDE, ARRAY_SIZE(LED_REGION_L_SIDE),
115 hsv_cl_purple);
116 loop_colorset(LED_REGION_R_SIDE, ARRAY_SIZE(LED_REGION_R_SIDE),
117 hsv_cl_purple);
114 118
115 switch(get_highest_layer(layer_state)){ // special handling per layer 119 switch(get_highest_layer(layer_state)){ // special handling per layer
116 case 1: //layer 1 120 case 1: //layer 1
117 //rgb_matrix_set_color_all(RGB_AZURE); 121 //rgb_matrix_set_color_all(RGB_AZURE);
118 loop_colorset(LED_REGION_NUMPAD, (sizeof(LED_REGION_NUMPAD) / sizeof(LED_REGION_NUMPAD[0])), hsv_cl_numpad); 122 loop_colorset(LED_REGION_NUMPAD,
119 loop_colorset(LED_REGION_OTHER, (sizeof(LED_REGION_OTHER) / sizeof(LED_REGION_OTHER[0])), hsv_cl_mods); 123 ARRAY_SIZE(LED_REGION_NUMPAD), hsv_cl_numpad);
124 loop_colorset(LED_REGION_OTHER, ARRAY_SIZE(LED_REGION_OTHER),
125 hsv_cl_mods);
120 break; 126 break;
121 default: //layer 0 127 default: //layer 0
122 // 128 //
@@ -148,7 +154,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
148 rgb_matrix_set_color(LED_L6, bad_rgb.r, bad_rgb.g, bad_rgb.b); 154 rgb_matrix_set_color(LED_L6, bad_rgb.r, bad_rgb.g, bad_rgb.b);
149 rgb_matrix_set_color(LED_L7, bad_rgb.r, bad_rgb.g, bad_rgb.b); 155 rgb_matrix_set_color(LED_L7, bad_rgb.r, bad_rgb.g, bad_rgb.b);
150 rgb_matrix_set_color(LED_L8, bad_rgb.r, bad_rgb.g, bad_rgb.b); 156 rgb_matrix_set_color(LED_L8, bad_rgb.r, bad_rgb.g, bad_rgb.b);
151 loop_colorset(LED_REGION_CAPS, (sizeof(LED_REGION_CAPS) / sizeof(LED_REGION_CAPS[0])), hsv_cl_bad); 157 loop_colorset(LED_REGION_CAPS, ARRAY_SIZE(LED_REGION_CAPS),
158 hsv_cl_bad);
152 } 159 }
153 } 160 }
154#endif 161#endif
diff --git a/keyboards/gmmk/pro/rev1/ansi/keymaps/gourdo1/keymap.c b/keyboards/gmmk/pro/rev1/ansi/keymaps/gourdo1/keymap.c
index ab98693649..9b20399e00 100644
--- a/keyboards/gmmk/pro/rev1/ansi/keymaps/gourdo1/keymap.c
+++ b/keyboards/gmmk/pro/rev1/ansi/keymaps/gourdo1/keymap.c
@@ -538,7 +538,7 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
538 538
539 } else if (paddle_lives == 0) { 539 } else if (paddle_lives == 0) {
540 // Game over 540 // Game over
541 for (uint8_t i = 0; i < sizeof(LED_GAME_OVER) / sizeof(LED_GAME_OVER[0]); i++) { 541 for (uint8_t i = 0; i < ARRAY_SIZE(LED_GAME_OVER); i++) {
542 rgb_matrix_set_color(LED_GAME_OVER[i], RGB_RED); 542 rgb_matrix_set_color(LED_GAME_OVER[i], RGB_RED);
543 } 543 }
544 544
diff --git a/keyboards/gmmk/pro/rev1/ansi/keymaps/paddlegame/keymap.c b/keyboards/gmmk/pro/rev1/ansi/keymaps/paddlegame/keymap.c
index e59db7b984..164ff67e22 100644
--- a/keyboards/gmmk/pro/rev1/ansi/keymaps/paddlegame/keymap.c
+++ b/keyboards/gmmk/pro/rev1/ansi/keymaps/paddlegame/keymap.c
@@ -201,15 +201,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
201 else { ++rgb_value.r; } 201 else { ++rgb_value.r; }
202 } 202 }
203 203
204 for (uint8_t i=0; i<sizeof(LED_RGB)/sizeof(LED_RGB[0]); i++) { 204 for (uint8_t i=0; i<ARRAY_SIZE(LED_RGB); i++) {
205 rgb_matrix_set_color(LED_RGB[i], rgb_value.r, rgb_value.g, rgb_value.b); 205 rgb_matrix_set_color(LED_RGB[i], rgb_value.r, rgb_value.g, rgb_value.b);
206 } 206 }
207 207
208 for (uint8_t i=0; i<sizeof(LED_WHITE)/sizeof(LED_WHITE[0]); i++) { 208 for (uint8_t i=0; i<ARRAY_SIZE(LED_WHITE); i++) {
209 rgb_matrix_set_color(LED_WHITE[i], RGB_WHITE); 209 rgb_matrix_set_color(LED_WHITE[i], RGB_WHITE);
210 } 210 }
211 211
212 for (uint8_t i=0; i<sizeof(LED_GREEN)/sizeof(LED_GREEN[0]); i++) { 212 for (uint8_t i=0; i<ARRAY_SIZE(LED_GREEN); i++) {
213 rgb_matrix_set_color(LED_GREEN[i], RGB_GREEN); 213 rgb_matrix_set_color(LED_GREEN[i], RGB_GREEN);
214 } 214 }
215 215
@@ -274,7 +274,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
274 274
275 } else if (paddle_lives == 0) { 275 } else if (paddle_lives == 0) {
276 // Game over 276 // Game over
277 for (uint8_t i=0; i<sizeof(LED_GAME_OVER)/sizeof(LED_GAME_OVER[0]); i++) { 277 for (uint8_t i=0; i<ARRAY_SIZE(LED_GAME_OVER); i++) {
278 rgb_matrix_set_color(LED_GAME_OVER[i], RGB_RED); 278 rgb_matrix_set_color(LED_GAME_OVER[i], RGB_RED);
279 } 279 }
280 280
@@ -439,12 +439,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
439 439
440 rgb_matrix_set_color(LED_CAPS, RGB_WHITE); 440 rgb_matrix_set_color(LED_CAPS, RGB_WHITE);
441 if (caps_flash_on) { 441 if (caps_flash_on) {
442 for (uint8_t i=0; i<sizeof(LED_SIDE_LEFT)/sizeof(LED_SIDE_LEFT[0]); i++) { 442 for (uint8_t i=0; i<ARRAY_SIZE(LED_SIDE_LEFT); i++) {
443 rgb_matrix_set_color(LED_SIDE_LEFT[i], RGB_RED); 443 rgb_matrix_set_color(LED_SIDE_LEFT[i], RGB_RED);
444 rgb_matrix_set_color(LED_SIDE_RIGHT[i], RGB_RED); 444 rgb_matrix_set_color(LED_SIDE_RIGHT[i], RGB_RED);
445 } 445 }
446 } else { 446 } else {
447 for (uint8_t i=0; i<sizeof(LED_SIDE_LEFT)/sizeof(LED_SIDE_LEFT[0]); i++) { 447 for (uint8_t i=0; i<ARRAY_SIZE(LED_SIDE_LEFT); i++) {
448 rgb_matrix_set_color(LED_SIDE_LEFT[i], 0, 0, 0); 448 rgb_matrix_set_color(LED_SIDE_LEFT[i], 0, 0, 0);
449 rgb_matrix_set_color(LED_SIDE_RIGHT[i], 0, 0, 0); 449 rgb_matrix_set_color(LED_SIDE_RIGHT[i], 0, 0, 0);
450 } 450 }
diff --git a/keyboards/gmmk/pro/rev1/iso/keymaps/chofstede/keymap.c b/keyboards/gmmk/pro/rev1/iso/keymaps/chofstede/keymap.c
index b28809fdf6..fd941883c5 100644
--- a/keyboards/gmmk/pro/rev1/iso/keymaps/chofstede/keymap.c
+++ b/keyboards/gmmk/pro/rev1/iso/keymaps/chofstede/keymap.c
@@ -84,7 +84,7 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
84 } 84 }
85 HSV tempHSV = {.h = 0, .s = 255, .v = current_value}; 85 HSV tempHSV = {.h = 0, .s = 255, .v = current_value};
86 RGB tempRGB = hsv_to_rgb(tempHSV); 86 RGB tempRGB = hsv_to_rgb(tempHSV);
87 for (uint8_t i = 0; i < sizeof(left_side_leds) / sizeof(left_side_leds[0]); i++) { 87 for (uint8_t i = 0; i < ARRAY_SIZE(left_side_leds); i++) {
88 rgb_matrix_set_color(left_side_leds[i], tempRGB.r, tempRGB.g, tempRGB.b); 88 rgb_matrix_set_color(left_side_leds[i], tempRGB.r, tempRGB.g, tempRGB.b);
89 rgb_matrix_set_color(right_side_leds[i], tempRGB.r, tempRGB.g, tempRGB.b); 89 rgb_matrix_set_color(right_side_leds[i], tempRGB.r, tempRGB.g, tempRGB.b);
90 } 90 }
@@ -95,7 +95,7 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
95 case 2: //layer one 95 case 2: //layer one
96 break; 96 break;
97 case 1: 97 case 1:
98 for (uint8_t i = 0; i < sizeof(l2_functions) / sizeof(l2_functions[0]); i++) { 98 for (uint8_t i = 0; i < ARRAY_SIZE(l2_functions); i++) {
99 RGB_MATRIX_INDICATOR_SET_COLOR(l2_functions[i], 255, 0, 0); 99 RGB_MATRIX_INDICATOR_SET_COLOR(l2_functions[i], 255, 0, 0);
100 } 100 }
101 break; 101 break;
diff --git a/keyboards/gmmk/pro/rev1/iso/keymaps/gourdo1/keymap.c b/keyboards/gmmk/pro/rev1/iso/keymaps/gourdo1/keymap.c
index 30e8fc5f44..004a8c2014 100644
--- a/keyboards/gmmk/pro/rev1/iso/keymaps/gourdo1/keymap.c
+++ b/keyboards/gmmk/pro/rev1/iso/keymaps/gourdo1/keymap.c
@@ -551,7 +551,7 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
551 551
552 } else if (paddle_lives == 0) { 552 } else if (paddle_lives == 0) {
553 // Game over 553 // Game over
554 for (uint8_t i = 0; i < sizeof(LED_GAME_OVER) / sizeof(LED_GAME_OVER[0]); i++) { 554 for (uint8_t i = 0; i < ARRAY_SIZE(LED_GAME_OVER); i++) {
555 rgb_matrix_set_color(LED_GAME_OVER[i], RGB_RED); 555 rgb_matrix_set_color(LED_GAME_OVER[i], RGB_RED);
556 } 556 }
557 557
diff --git a/keyboards/gopolar/gg86/keymaps/horrortroll/keymap_stuff.h b/keyboards/gopolar/gg86/keymaps/horrortroll/keymap_stuff.h
index ad7a3238ce..e5f5c91151 100644
--- a/keyboards/gopolar/gg86/keymaps/horrortroll/keymap_stuff.h
+++ b/keyboards/gopolar/gg86/keymaps/horrortroll/keymap_stuff.h
@@ -118,7 +118,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
118 {{205, 250, 255}, {140, 215, 125}, false }, 118 {{205, 250, 255}, {140, 215, 125}, false },
119 }; 119 };
120 120
121 uint8_t gp_length = sizeof(gradient_presets)/sizeof(gradient_presets[0]); 121 uint8_t gp_length = ARRAY_SIZE(gradient_presets);
122 122
123 switch (keycode) { 123 switch (keycode) {
124 case G1_HUI: 124 case G1_HUI:
diff --git a/keyboards/gopolar/gg86/lib/wave.h b/keyboards/gopolar/gg86/lib/wave.h
index 11a3198ab1..f4e5e5052c 100644
--- a/keyboards/gopolar/gg86/lib/wave.h
+++ b/keyboards/gopolar/gg86/lib/wave.h
@@ -69,7 +69,7 @@ void add_keylog(uint16_t keycode) {
69 keycode = 0; 69 keycode = 0;
70 } 70 }
71 71
72 if (keycode < (sizeof(code_to_name) / sizeof(char))) { 72 if (keycode < ARRAY_SIZE(code_to_name)) {
73 char log_char = pgm_read_byte(&code_to_name[keycode]); 73 char log_char = pgm_read_byte(&code_to_name[keycode]);
74 74
75 for (uint8_t j = 0; j < OLED_FONT_WIDTH; j++) { 75 for (uint8_t j = 0; j < OLED_FONT_WIDTH; j++) {
diff --git a/keyboards/handwired/lagrange/keymaps/dpapavas/keymap.c b/keyboards/handwired/lagrange/keymaps/dpapavas/keymap.c
index c2eb4406d1..bc5b025b48 100644
--- a/keyboards/handwired/lagrange/keymaps/dpapavas/keymap.c
+++ b/keyboards/handwired/lagrange/keymaps/dpapavas/keymap.c
@@ -191,8 +191,8 @@ void keyboard_post_init_user(void) {
191 const pin_t pins[] = {D0, D1, D2}; 191 const pin_t pins[] = {D0, D1, D2};
192 uint8_t i, j; 192 uint8_t i, j;
193 193
194 for (i = 0 ; i < sizeof(pins) / sizeof(pins[0]) + 2 ; i += 1) { 194 for (i = 0 ; i < ARRAY_SIZE(pins) + 2 ; i += 1) {
195 for (j = 0 ; j < sizeof(pins) / sizeof(pins[0]) ; j += 1) { 195 for (j = 0 ; j < ARRAY_SIZE(pins); j += 1) {
196 setPinOutput(pins[j]); 196 setPinOutput(pins[j]);
197 writePin(pins[j], (j == i || j == i - 1)); 197 writePin(pins[j], (j == i || j == i - 1));
198 } 198 }
diff --git a/keyboards/handwired/myskeeb/oled.c b/keyboards/handwired/myskeeb/oled.c
index 081ca8395a..3f43590b8e 100644
--- a/keyboards/handwired/myskeeb/oled.c
+++ b/keyboards/handwired/myskeeb/oled.c
@@ -183,7 +183,7 @@ void add_keylog(uint16_t keycode) {
183 keylog_str[i] = keylog_str[i - 1]; 183 keylog_str[i] = keylog_str[i - 1];
184 } 184 }
185 185
186 if (keycode < (sizeof(code_to_name) / sizeof(char))) { 186 if (keycode < ARRAY_SIZE(code_to_name)) {
187 keylog_str[0] = pgm_read_byte(&code_to_name[keycode]); 187 keylog_str[0] = pgm_read_byte(&code_to_name[keycode]);
188 } 188 }
189} 189}
diff --git a/keyboards/handwired/nicekey/keymaps/default/keymap.c b/keyboards/handwired/nicekey/keymaps/default/keymap.c
index d7539a5c17..a4391eaa30 100644
--- a/keyboards/handwired/nicekey/keymaps/default/keymap.c
+++ b/keyboards/handwired/nicekey/keymaps/default/keymap.c
@@ -116,7 +116,7 @@ PGM_P const sentences[] PROGMEM = {
116 116
117bool process_record_user(uint16_t keycode, keyrecord_t *record) { 117bool process_record_user(uint16_t keycode, keyrecord_t *record) {
118 if (record->event.pressed) { 118 if (record->event.pressed) {
119 int sentences_size = sizeof(sentences) / sizeof(sentences[0]); 119 int sentences_size = ARRAY_SIZE(sentences);
120 int i = rand() % sentences_size; 120 int i = rand() % sentences_size;
121 121
122 switch (keycode) { 122 switch (keycode) {
diff --git a/keyboards/handwired/onekey/keymaps/chibios_waiting_test/keymap.c b/keyboards/handwired/onekey/keymaps/chibios_waiting_test/keymap.c
index ecf67d3b3c..65983c8dd8 100644
--- a/keyboards/handwired/onekey/keymaps/chibios_waiting_test/keymap.c
+++ b/keyboards/handwired/onekey/keymaps/chibios_waiting_test/keymap.c
@@ -34,11 +34,11 @@ static const uint32_t waiting_values[] = {0, 1, 5, 10, 25, 50, 100, 150, 200, 50
34void housekeeping_task_user(void) { 34void housekeeping_task_user(void) {
35 static uint32_t last_bench = 0; 35 static uint32_t last_bench = 0;
36 if (timer_elapsed32(last_bench) > 500) { 36 if (timer_elapsed32(last_bench) > 500) {
37 for (int i = 0; i < (sizeof(waiting_values) / sizeof(waiting_values[0])); i++) { 37 for (int i = 0; i < ARRAY_SIZE(waiting_values); i++) {
38 wait_us_polling_with_strobe(waiting_values[i]); 38 wait_us_polling_with_strobe(waiting_values[i]);
39 wait_us(10); 39 wait_us(10);
40 } 40 }
41 for (int i = 0; i < (sizeof(waiting_values) / sizeof(waiting_values[0])); i++) { 41 for (int i = 0; i < ARRAY_SIZE(waiting_values); i++) {
42 wait_us_yield_with_strobe(waiting_values[i]); 42 wait_us_yield_with_strobe(waiting_values[i]);
43 wait_us(10); 43 wait_us(10);
44 } 44 }
diff --git a/keyboards/handwired/promethium/keymaps/default/keymap.c b/keyboards/handwired/promethium/keymaps/default/keymap.c
index 77f83361e6..fcfcf51f24 100644
--- a/keyboards/handwired/promethium/keymaps/default/keymap.c
+++ b/keyboards/handwired/promethium/keymaps/default/keymap.c
@@ -55,7 +55,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
55#endif 55#endif
56#include "outputselect.h" 56#include "outputselect.h"
57#include "led.h" 57#include "led.h"
58#define COUNT(x) (sizeof (x) / sizeof (*(x))) 58#define COUNT(x) ARRAY_SIZE((x))
59 59
60#define KC_WWWB KC_WWW_BACK 60#define KC_WWWB KC_WWW_BACK
61#define KC_WWWF KC_WWW_FORWARD 61#define KC_WWWF KC_WWW_FORWARD
diff --git a/keyboards/handwired/promethium/keymaps/priyadi/keymap.c b/keyboards/handwired/promethium/keymaps/priyadi/keymap.c
index 31ce811e53..4df95111a7 100644
--- a/keyboards/handwired/promethium/keymaps/priyadi/keymap.c
+++ b/keyboards/handwired/promethium/keymaps/priyadi/keymap.c
@@ -57,7 +57,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
57#include "outputselect.h" 57#include "outputselect.h"
58#endif 58#endif
59#include "led.h" 59#include "led.h"
60#define COUNT(x) (sizeof (x) / sizeof (*(x))) 60#define COUNT(x) ARRAY_SIZE((x))
61 61
62#define KC_WWWB KC_WWW_BACK 62#define KC_WWWB KC_WWW_BACK
63#define KC_WWWF KC_WWW_FORWARD 63#define KC_WWWF KC_WWW_FORWARD
diff --git a/keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c b/keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c
index ba0018a70f..7e15761a98 100644
--- a/keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c
+++ b/keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c
@@ -159,7 +159,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
159 do { 159 do {
160 MATRIX_DEBUG_DELAY_START(); 160 MATRIX_DEBUG_DELAY_START();
161 is_pressed = false; 161 is_pressed = false;
162 for (uint8_t i = 0; i < sizeof(delay_ports) / sizeof(pin_t); i++) { 162 for (uint8_t i = 0; i < ARRAY_SIZE(delay_ports); i++) {
163# ifdef MATRIX_IO_DELAY_MULSEL 163# ifdef MATRIX_IO_DELAY_MULSEL
164 writePin(MATRIX_MUL_SELECT, delay_sel[i]); 164 writePin(MATRIX_MUL_SELECT, delay_sel[i]);
165 waitInputPinDelay(); 165 waitInputPinDelay();
diff --git a/keyboards/horrortroll/handwired_k552/keymaps/default/keymap_stuff.h b/keyboards/horrortroll/handwired_k552/keymaps/default/keymap_stuff.h
index a97b46e5e4..8c4f9d0d4b 100644
--- a/keyboards/horrortroll/handwired_k552/keymaps/default/keymap_stuff.h
+++ b/keyboards/horrortroll/handwired_k552/keymaps/default/keymap_stuff.h
@@ -110,7 +110,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
110 {{205, 250, 255}, {140, 215, 125}, false }, 110 {{205, 250, 255}, {140, 215, 125}, false },
111 }; 111 };
112 112
113 uint8_t gp_length = sizeof(gradient_presets)/sizeof(gradient_presets[0]); 113 uint8_t gp_length = ARRAY_SIZE(gradient_presets);
114 114
115 switch (keycode) { 115 switch (keycode) {
116 case G1_HUI: 116 case G1_HUI:
diff --git a/keyboards/horrortroll/handwired_k552/keymaps/via/keymap_stuff.h b/keyboards/horrortroll/handwired_k552/keymaps/via/keymap_stuff.h
index a97b46e5e4..8c4f9d0d4b 100644
--- a/keyboards/horrortroll/handwired_k552/keymaps/via/keymap_stuff.h
+++ b/keyboards/horrortroll/handwired_k552/keymaps/via/keymap_stuff.h
@@ -110,7 +110,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
110 {{205, 250, 255}, {140, 215, 125}, false }, 110 {{205, 250, 255}, {140, 215, 125}, false },
111 }; 111 };
112 112
113 uint8_t gp_length = sizeof(gradient_presets)/sizeof(gradient_presets[0]); 113 uint8_t gp_length = ARRAY_SIZE(gradient_presets);
114 114
115 switch (keycode) { 115 switch (keycode) {
116 case G1_HUI: 116 case G1_HUI:
diff --git a/keyboards/horrortroll/handwired_k552/lib/wave.c b/keyboards/horrortroll/handwired_k552/lib/wave.c
index 79b4e0ced7..700f73aee5 100644
--- a/keyboards/horrortroll/handwired_k552/lib/wave.c
+++ b/keyboards/horrortroll/handwired_k552/lib/wave.c
@@ -68,7 +68,7 @@ void add_keylog(uint16_t keycode) {
68 keycode = 0; 68 keycode = 0;
69 } 69 }
70 70
71 if (keycode < (sizeof(code_to_name) / sizeof(char))) { 71 if (keycode < ARRAY_SIZE(code_to_name)) {
72 char log_char = pgm_read_byte(&code_to_name[keycode]); 72 char log_char = pgm_read_byte(&code_to_name[keycode]);
73 73
74 for (uint8_t j = 0; j < OLED_FONT_WIDTH; j++) { 74 for (uint8_t j = 0; j < OLED_FONT_WIDTH; j++) {
diff --git a/keyboards/lfkeyboards/lfkpad/keymaps/pascalpfeil/keymap.c b/keyboards/lfkeyboards/lfkpad/keymaps/pascalpfeil/keymap.c
index 667e8859e2..38eb656892 100644
--- a/keyboards/lfkeyboards/lfkpad/keymaps/pascalpfeil/keymap.c
+++ b/keyboards/lfkeyboards/lfkpad/keymaps/pascalpfeil/keymap.c
@@ -58,7 +58,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
58}; 58};
59 59
60const uint8_t number_leds[] = {8, 9, 10, 11, 12, 13, 15, 16, 17}; 60const uint8_t number_leds[] = {8, 9, 10, 11, 12, 13, 15, 16, 17};
61const uint8_t number_leds_size = sizeof(number_leds) / sizeof(uint8_t); 61const uint8_t number_leds_size = ARRAY_SIZE(number_leds);
62 62
63bool led_update_user(led_t led_state) { 63bool led_update_user(led_t led_state) {
64 for (uint8_t i = 0; i < number_leds_size; i++) 64 for (uint8_t i = 0; i < number_leds_size; i++)
diff --git a/keyboards/massdrop/ctrl/keymaps/responsive_pattern/keymap.c b/keyboards/massdrop/ctrl/keymaps/responsive_pattern/keymap.c
index ddcf30b68d..eee2eaf628 100644
--- a/keyboards/massdrop/ctrl/keymaps/responsive_pattern/keymap.c
+++ b/keyboards/massdrop/ctrl/keymaps/responsive_pattern/keymap.c
@@ -129,8 +129,7 @@ static uint8_t COLOR_PATTERNS[][COLOR_PATTERN_RGB_COUNT][3] = {
129 { 66, 66, 66}, { 45, 45, 45}, { 23, 23, 23}, 129 { 66, 66, 66}, { 45, 45, 45}, { 23, 23, 23},
130 }, 130 },
131}; 131};
132static const uint8_t COLOR_PATTERNS_COUNT = ( 132static const uint8_t COLOR_PATTERNS_COUNT = ARRAY_SIZE(COLOR_PATTERNS);
133 sizeof(COLOR_PATTERNS) / sizeof(COLOR_PATTERNS[0]));
134 133
135/** 134/**
136 * trimed down version of `ISSI3733_LED_MAP`: 135 * trimed down version of `ISSI3733_LED_MAP`:
diff --git a/keyboards/mechwild/mercutio/keymaps/fearless_spiff/keymap.c b/keyboards/mechwild/mercutio/keymaps/fearless_spiff/keymap.c
index 50b1b6471c..9dbd4d3f19 100644
--- a/keyboards/mechwild/mercutio/keymaps/fearless_spiff/keymap.c
+++ b/keyboards/mechwild/mercutio/keymaps/fearless_spiff/keymap.c
@@ -83,7 +83,7 @@ static const encoder_key PROGMEM encoder_keys[] = {
83 {"Play", "", "", KC_MEDIA_PLAY_PAUSE} 83 {"Play", "", "", KC_MEDIA_PLAY_PAUSE}
84}; 84};
85 85
86#define NUMBER_OF_ENCODER_KEYS sizeof(encoder_keys)/sizeof(encoder_keys[0]) 86#define NUMBER_OF_ENCODER_KEYS ARRAY_SIZE(encoder_keys)
87 87
88static uint8_t selected_encoder_key_id = 0; 88static uint8_t selected_encoder_key_id = 0;
89static encoder_key selected_encoder_key; 89static encoder_key selected_encoder_key;
diff --git a/keyboards/mechwild/mercutio/keymaps/fearless_spiff_en/keymap.c b/keyboards/mechwild/mercutio/keymaps/fearless_spiff_en/keymap.c
index 267d3add14..9b28c68672 100644
--- a/keyboards/mechwild/mercutio/keymaps/fearless_spiff_en/keymap.c
+++ b/keyboards/mechwild/mercutio/keymaps/fearless_spiff_en/keymap.c
@@ -82,7 +82,7 @@ static const encoder_key PROGMEM encoder_keys[] = {
82 {"Play", "", "", KC_MEDIA_PLAY_PAUSE} 82 {"Play", "", "", KC_MEDIA_PLAY_PAUSE}
83}; 83};
84 84
85#define NUMBER_OF_ENCODER_KEYS sizeof(encoder_keys)/sizeof(encoder_keys[0]) 85#define NUMBER_OF_ENCODER_KEYS ARRAY_SIZE(encoder_keys)
86 86
87static uint8_t selected_encoder_key_id = 0; 87static uint8_t selected_encoder_key_id = 0;
88static encoder_key selected_encoder_key; 88static encoder_key selected_encoder_key;
diff --git a/keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c b/keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c
index 5c22abee3f..a8f1d488d4 100755
--- a/keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c
+++ b/keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c
@@ -71,7 +71,7 @@ static const keycodedescType PROGMEM keyselection[] = {
71 {"FLASH", QK_BOOT}, // firmware flash mode 71 {"FLASH", QK_BOOT}, // firmware flash mode
72}; 72};
73 73
74#define MAX_KEYSELECTION sizeof(keyselection)/sizeof(keyselection[0]) 74#define MAX_KEYSELECTION ARRAY_SIZE(keyselection)
75 75
76static uint8_t selectedkey_idx = 0; 76static uint8_t selectedkey_idx = 0;
77static keycodedescType selectedkey_rec; 77static keycodedescType selectedkey_rec;
diff --git a/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c b/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c
index b0288c5d7a..58db97d093 100644
--- a/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c
+++ b/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c
@@ -178,7 +178,7 @@ static const keycodedescType PROGMEM keyselection[] = {
178 {"QK_BOOT", QK_BOOT}, // firmware flash mode 178 {"QK_BOOT", QK_BOOT}, // firmware flash mode
179}; 179};
180 180
181#define MAX_KEYSELECTION sizeof(keyselection)/sizeof(keyselection[0]) 181#define MAX_KEYSELECTION ARRAY_SIZE(keyselection)
182 182
183static uint8_t selectedkey_idx = 0; 183static uint8_t selectedkey_idx = 0;
184static keycodedescType selectedkey_rec; 184static keycodedescType selectedkey_rec;
diff --git a/keyboards/mechwild/puckbuddy/puckbuddy.c b/keyboards/mechwild/puckbuddy/puckbuddy.c
index b82d06f565..495cb7e825 100644
--- a/keyboards/mechwild/puckbuddy/puckbuddy.c
+++ b/keyboards/mechwild/puckbuddy/puckbuddy.c
@@ -16,7 +16,7 @@
16 16
17keyboard_config_t keyboard_config; 17keyboard_config_t keyboard_config;
18uint16_t dpi_array[] = GLIDEPOINT_DPI_OPTIONS; 18uint16_t dpi_array[] = GLIDEPOINT_DPI_OPTIONS;
19#define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t)) 19#define DPI_OPTION_SIZE ARRAY_SIZE(dpi_array)
20 20
21void board_init(void) { 21void board_init(void) {
22 // B9 is configured as I2C1_SDA in the board file; that function must be 22 // B9 is configured as I2C1_SDA in the board file; that function must be
diff --git a/keyboards/mitosis/keymaps/datagrok/keymap.c b/keyboards/mitosis/keymaps/datagrok/keymap.c
index 7c77eb882f..848af3de00 100644
--- a/keyboards/mitosis/keymaps/datagrok/keymap.c
+++ b/keyboards/mitosis/keymaps/datagrok/keymap.c
@@ -97,7 +97,7 @@ const bool defaultlayers[] = {
97 [_xN] = false, 97 [_xN] = false,
98 [_xF] = false, 98 [_xF] = false,
99}; 99};
100const size_t defaultlayers_n = sizeof(defaultlayers) / sizeof(defaultlayers[0]); 100const size_t defaultlayers_n = ARRAY_SIZE(defaultlayers);
101 101
102// New keycode KC_LAYO rotates between available default layers (for e.g., 102// New keycode KC_LAYO rotates between available default layers (for e.g.,
103// selecting a base layout). Shift+KC_LAYO makes the current one persistent. 103// selecting a base layout). Shift+KC_LAYO makes the current one persistent.
diff --git a/keyboards/mwstudio/mw65_rgb/keymaps/horrortroll/keymap_stuff.h b/keyboards/mwstudio/mw65_rgb/keymaps/horrortroll/keymap_stuff.h
index c8b8015363..eea031698a 100644
--- a/keyboards/mwstudio/mw65_rgb/keymaps/horrortroll/keymap_stuff.h
+++ b/keyboards/mwstudio/mw65_rgb/keymaps/horrortroll/keymap_stuff.h
@@ -116,7 +116,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
116 {{205, 250, 255}, {140, 215, 125}, false }, 116 {{205, 250, 255}, {140, 215, 125}, false },
117 }; 117 };
118 118
119 uint8_t gp_length = sizeof(gradient_presets)/sizeof(gradient_presets[0]); 119 uint8_t gp_length = ARRAY_SIZE(gradient_presets);
120 120
121 switch (keycode) { 121 switch (keycode) {
122 case G1_HUI: 122 case G1_HUI:
diff --git a/keyboards/mxss/keymaps/default/keymap.c b/keyboards/mxss/keymaps/default/keymap.c
index 519547f15a..3b7150f7fa 100644
--- a/keyboards/mxss/keymaps/default/keymap.c
+++ b/keyboards/mxss/keymaps/default/keymap.c
@@ -27,7 +27,7 @@ hs_set layer_colors[4] = {
27 [2] = {.hue = 36, .sat = 255}, // Color for Layer 2 27 [2] = {.hue = 36, .sat = 255}, // Color for Layer 2
28 [3] = {.hue = 185, .sat = 255}, // Color for Layer 3 28 [3] = {.hue = 185, .sat = 255}, // Color for Layer 3
29}; 29};
30size_t lc_size = sizeof(layer_colors) / sizeof(uint16_t); 30size_t lc_size = ARRAY_SIZE(layer_colors);
31 31
32// Use NEW_SAFE_RANGE to define new custom keycodes in order to not overwrite the ones used for front LED control 32// Use NEW_SAFE_RANGE to define new custom keycodes in order to not overwrite the ones used for front LED control
33enum custom_keycodes { 33enum custom_keycodes {
diff --git a/keyboards/mxss/mxss_frontled.c b/keyboards/mxss/mxss_frontled.c
index 8bb93d5fd8..2ab9a27bea 100644
--- a/keyboards/mxss/mxss_frontled.c
+++ b/keyboards/mxss/mxss_frontled.c
@@ -36,7 +36,7 @@ __attribute__ ((weak))
36hs_set caps_color; 36hs_set caps_color;
37 37
38__attribute__ ((weak)) 38__attribute__ ((weak))
39size_t lc_size = sizeof(layer_colors) / sizeof(hs_set); 39size_t lc_size = ARRAY_SIZE(layer_colors);
40 40
41void fled_init(void) { 41void fled_init(void) {
42 // This checks both an EEPROM reset (from bootmagic lite, keycodes) 42 // This checks both an EEPROM reset (from bootmagic lite, keycodes)
diff --git a/keyboards/mxss/templates/keymap.c b/keyboards/mxss/templates/keymap.c
index a18cff77f0..48cab22852 100644
--- a/keyboards/mxss/templates/keymap.c
+++ b/keyboards/mxss/templates/keymap.c
@@ -27,7 +27,7 @@ hs_set layer_colors[4] = {
27 [2] = {.hue = 36, .sat = 255}, // Color for Layer 2 27 [2] = {.hue = 36, .sat = 255}, // Color for Layer 2
28 [3] = {.hue = 185, .sat = 255}, // Color for Layer 3 28 [3] = {.hue = 185, .sat = 255}, // Color for Layer 3
29}; 29};
30size_t lc_size = sizeof(layer_colors) / sizeof(uint16_t); 30size_t lc_size = ARRAY_SIZE(layer_colors);
31 31
32// Use NEW_SAFE_RANGE to define new custom keycodes in order to not overwrite the ones used for front LED control 32// Use NEW_SAFE_RANGE to define new custom keycodes in order to not overwrite the ones used for front LED control
33enum custom_keycodes { 33enum custom_keycodes {
diff --git a/keyboards/ploopyco/mouse/mouse.c b/keyboards/ploopyco/mouse/mouse.c
index 19bc17738e..abcaa276d9 100644
--- a/keyboards/ploopyco/mouse/mouse.c
+++ b/keyboards/ploopyco/mouse/mouse.c
@@ -49,7 +49,7 @@
49 49
50keyboard_config_t keyboard_config; 50keyboard_config_t keyboard_config;
51uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS; 51uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS;
52#define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t)) 52#define DPI_OPTION_SIZE ARRAY_SIZE(dpi_array)
53 53
54// TODO: Implement libinput profiles 54// TODO: Implement libinput profiles
55// https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html 55// https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html
@@ -202,7 +202,7 @@ void keyboard_pre_init_kb(void) {
202#ifdef UNUSABLE_PINS 202#ifdef UNUSABLE_PINS
203 const pin_t unused_pins[] = UNUSABLE_PINS; 203 const pin_t unused_pins[] = UNUSABLE_PINS;
204 204
205 for (uint8_t i = 0; i < (sizeof(unused_pins) / sizeof(pin_t)); i++) { 205 for (uint8_t i = 0; i < ARRAY_SIZE(unused_pins); i++) {
206 setPinOutput(unused_pins[i]); 206 setPinOutput(unused_pins[i]);
207 writePinLow(unused_pins[i]); 207 writePinLow(unused_pins[i]);
208 } 208 }
diff --git a/keyboards/ploopyco/trackball/trackball.c b/keyboards/ploopyco/trackball/trackball.c
index 786b40f9e8..c96bf15cba 100644
--- a/keyboards/ploopyco/trackball/trackball.c
+++ b/keyboards/ploopyco/trackball/trackball.c
@@ -49,7 +49,7 @@
49 49
50keyboard_config_t keyboard_config; 50keyboard_config_t keyboard_config;
51uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS; 51uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS;
52#define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t)) 52#define DPI_OPTION_SIZE ARRAY_SIZE(dpi_array)
53 53
54// TODO: Implement libinput profiles 54// TODO: Implement libinput profiles
55// https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html 55// https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html
@@ -207,7 +207,7 @@ void keyboard_pre_init_kb(void) {
207#ifdef UNUSABLE_PINS 207#ifdef UNUSABLE_PINS
208 const pin_t unused_pins[] = UNUSABLE_PINS; 208 const pin_t unused_pins[] = UNUSABLE_PINS;
209 209
210 for (uint8_t i = 0; i < (sizeof(unused_pins) / sizeof(pin_t)); i++) { 210 for (uint8_t i = 0; i < ARRAY_SIZE(unused_pins); i++) {
211 setPinOutput(unused_pins[i]); 211 setPinOutput(unused_pins[i]);
212 writePinLow(unused_pins[i]); 212 writePinLow(unused_pins[i]);
213 } 213 }
diff --git a/keyboards/ploopyco/trackball_mini/trackball_mini.c b/keyboards/ploopyco/trackball_mini/trackball_mini.c
index df13912af4..dc3708fd51 100644
--- a/keyboards/ploopyco/trackball_mini/trackball_mini.c
+++ b/keyboards/ploopyco/trackball_mini/trackball_mini.c
@@ -57,7 +57,7 @@
57 57
58keyboard_config_t keyboard_config; 58keyboard_config_t keyboard_config;
59uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS; 59uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS;
60#define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t)) 60#define DPI_OPTION_SIZE ARRAY_SIZE(dpi_array)
61 61
62// TODO: Implement libinput profiles 62// TODO: Implement libinput profiles
63// https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html 63// https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html
@@ -203,7 +203,7 @@ void keyboard_pre_init_kb(void) {
203#ifdef UNUSABLE_PINS 203#ifdef UNUSABLE_PINS
204 const pin_t unused_pins[] = UNUSABLE_PINS; 204 const pin_t unused_pins[] = UNUSABLE_PINS;
205 205
206 for (uint8_t i = 0; i < (sizeof(unused_pins) / sizeof(pin_t)); i++) { 206 for (uint8_t i = 0; i < ARRAY_SIZE(unused_pins); i++) {
207 setPinOutput(unused_pins[i]); 207 setPinOutput(unused_pins[i]);
208 writePinLow(unused_pins[i]); 208 writePinLow(unused_pins[i]);
209 } 209 }
diff --git a/keyboards/ploopyco/trackball_nano/trackball_nano.c b/keyboards/ploopyco/trackball_nano/trackball_nano.c
index eb1d8e10b0..366918e134 100644
--- a/keyboards/ploopyco/trackball_nano/trackball_nano.c
+++ b/keyboards/ploopyco/trackball_nano/trackball_nano.c
@@ -50,7 +50,7 @@
50 50
51keyboard_config_t keyboard_config; 51keyboard_config_t keyboard_config;
52uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS; 52uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS;
53#define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t)) 53#define DPI_OPTION_SIZE ARRAY_SIZE(dpi_array)
54 54
55void cycle_dpi(void) { 55void cycle_dpi(void) {
56 keyboard_config.dpi_config = (keyboard_config.dpi_config + 1) % DPI_OPTION_SIZE; 56 keyboard_config.dpi_config = (keyboard_config.dpi_config + 1) % DPI_OPTION_SIZE;
@@ -89,7 +89,7 @@ void keyboard_pre_init_kb(void) {
89#ifdef UNUSABLE_PINS 89#ifdef UNUSABLE_PINS
90 const pin_t unused_pins[] = UNUSABLE_PINS; 90 const pin_t unused_pins[] = UNUSABLE_PINS;
91 91
92 for (uint8_t i = 0; i < (sizeof(unused_pins) / sizeof(pin_t)); i++) { 92 for (uint8_t i = 0; i < ARRAY_SIZE(unused_pins); i++) {
93 setPinOutput(unused_pins[i]); 93 setPinOutput(unused_pins[i]);
94 writePinLow(unused_pins[i]); 94 writePinLow(unused_pins[i]);
95 } 95 }
diff --git a/keyboards/rgbkb/pan/pan.c b/keyboards/rgbkb/pan/pan.c
index c367550e49..6a17456390 100644
--- a/keyboards/rgbkb/pan/pan.c
+++ b/keyboards/rgbkb/pan/pan.c
@@ -51,7 +51,7 @@ static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) {
51} 51}
52 52
53static void setled_all(uint8_t r, uint8_t g, uint8_t b) { 53static void setled_all(uint8_t r, uint8_t g, uint8_t b) {
54 for (int i = 0; i < sizeof(rgb_matrix_ws2812_array) / sizeof(rgb_matrix_ws2812_array[0]); i++) { 54 for (int i = 0; i < ARRAY_SIZE(rgb_matrix_ws2812_array); i++) {
55 setled(i, r, g, b); 55 setled(i, r, g, b);
56 } 56 }
57} 57}
diff --git a/keyboards/rgbkb/sol/keymaps/default/keymap.c b/keyboards/rgbkb/sol/keymaps/default/keymap.c
index 1ce18bc1ab..87241521ae 100644
--- a/keyboards/rgbkb/sol/keymaps/default/keymap.c
+++ b/keyboards/rgbkb/sol/keymaps/default/keymap.c
@@ -202,7 +202,7 @@ const rgb_matrix_f rgb_matrix_functions[6][2] = {
202#ifdef ENCODER_ENABLE 202#ifdef ENCODER_ENABLE
203 203
204static pin_t encoders_pad_a[] = ENCODERS_PAD_A; 204static pin_t encoders_pad_a[] = ENCODERS_PAD_A;
205#define NUMBER_OF_ENCODERS (sizeof(encoders_pad_a)/sizeof(pin_t)) 205#define NUMBER_OF_ENCODERS ARRAY_SIZE(encoders_pad_a)
206 206
207const uint16_t PROGMEM encoders[][NUMBER_OF_ENCODERS * 2][2] = { 207const uint16_t PROGMEM encoders[][NUMBER_OF_ENCODERS * 2][2] = {
208 [_QWERTY] = ENCODER_LAYOUT( 208 [_QWERTY] = ENCODER_LAYOUT(
diff --git a/keyboards/rgbkb/sol/keymaps/xyverz/keymap.c b/keyboards/rgbkb/sol/keymaps/xyverz/keymap.c
index cdd0c6620a..d042a4fe27 100644
--- a/keyboards/rgbkb/sol/keymaps/xyverz/keymap.c
+++ b/keyboards/rgbkb/sol/keymaps/xyverz/keymap.c
@@ -232,7 +232,7 @@ const rgb_matrix_f rgb_matrix_functions[6][2] = {
232#ifdef ENCODER_ENABLE 232#ifdef ENCODER_ENABLE
233 233
234static pin_t encoders_pad_a[] = ENCODERS_PAD_A; 234static pin_t encoders_pad_a[] = ENCODERS_PAD_A;
235#define NUMBER_OF_ENCODERS (sizeof(encoders_pad_a)/sizeof(pin_t)) 235#define NUMBER_OF_ENCODERS ARRAY_SIZE(encoders_pad_a)
236 236
237const uint16_t PROGMEM encoders[][NUMBER_OF_ENCODERS * 2][2] = { 237const uint16_t PROGMEM encoders[][NUMBER_OF_ENCODERS * 2][2] = {
238 [_QWERTY] = ENCODER_LAYOUT( \ 238 [_QWERTY] = ENCODER_LAYOUT( \
diff --git a/keyboards/rocketboard_16/keycode_lookup.c b/keyboards/rocketboard_16/keycode_lookup.c
index d967a03c31..cf25726880 100644
--- a/keyboards/rocketboard_16/keycode_lookup.c
+++ b/keyboards/rocketboard_16/keycode_lookup.c
@@ -18,7 +18,7 @@
18#include "print.h" 18#include "print.h"
19#include "via.h" 19#include "via.h"
20 20
21#define num_keycodes (sizeof(lookup_table)/sizeof(lookup_table[0])) 21#define num_keycodes ARRAY_SIZE(lookup_table)
22static char UNKNOWN_KEYCODE[] = "UNKNOWN"; 22static char UNKNOWN_KEYCODE[] = "UNKNOWN";
23 23
24int cmp(const void *v1, const void *v2) 24int cmp(const void *v1, const void *v2)
diff --git a/keyboards/torn/bongocat.c b/keyboards/torn/bongocat.c
index 21322c9536..9d6d9a85f5 100644
--- a/keyboards/torn/bongocat.c
+++ b/keyboards/torn/bongocat.c
@@ -18,8 +18,6 @@
18 18
19#ifdef OLED_ENABLE 19#ifdef OLED_ENABLE
20 20
21#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
22
23#define IDLE_SPEED 20 // idle below this wpm 21#define IDLE_SPEED 20 // idle below this wpm
24#define TAP_SPEED 60 // tap above this wpm 22#define TAP_SPEED 60 // tap above this wpm
25 23
diff --git a/keyboards/tzarc/djinn/djinn_portscan_matrix.c b/keyboards/tzarc/djinn/djinn_portscan_matrix.c
index f0ae9721f9..6fcfd48bba 100644
--- a/keyboards/tzarc/djinn/djinn_portscan_matrix.c
+++ b/keyboards/tzarc/djinn/djinn_portscan_matrix.c
@@ -92,11 +92,11 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) {
92 92
93void matrix_wait_for_interrupt(void) { 93void matrix_wait_for_interrupt(void) {
94 // Set up row/col pins and attach callback 94 // Set up row/col pins and attach callback
95 for (int i = 0; i < sizeof(col_pins) / sizeof(pin_t); ++i) { 95 for (int i = 0; i < ARRAY_SIZE(col_pins); ++i) {
96 setPinOutput(col_pins[i]); 96 setPinOutput(col_pins[i]);
97 writePinLow(col_pins[i]); 97 writePinLow(col_pins[i]);
98 } 98 }
99 for (int i = 0; i < sizeof(row_pins) / sizeof(pin_t); ++i) { 99 for (int i = 0; i < ARRAY_SIZE(row_pins); ++i) {
100 setPinInputHigh(row_pins[i]); 100 setPinInputHigh(row_pins[i]);
101 palEnableLineEvent(row_pins[i], PAL_EVENT_MODE_BOTH_EDGES); 101 palEnableLineEvent(row_pins[i], PAL_EVENT_MODE_BOTH_EDGES);
102 } 102 }
@@ -105,12 +105,12 @@ void matrix_wait_for_interrupt(void) {
105 __WFI(); 105 __WFI();
106 106
107 // Now that the interrupt has woken us up, reset all the row/col pins back to defaults 107 // Now that the interrupt has woken us up, reset all the row/col pins back to defaults
108 for (int i = 0; i < sizeof(row_pins) / sizeof(pin_t); ++i) { 108 for (int i = 0; i < ARRAY_SIZE(row_pins); ++i) {
109 palDisableLineEvent(row_pins[i]); 109 palDisableLineEvent(row_pins[i]);
110 writePinHigh(row_pins[i]); 110 writePinHigh(row_pins[i]);
111 setPinInputHigh(row_pins[i]); 111 setPinInputHigh(row_pins[i]);
112 } 112 }
113 for (int i = 0; i < sizeof(col_pins) / sizeof(pin_t); ++i) { 113 for (int i = 0; i < ARRAY_SIZE(col_pins); ++i) {
114 writePinHigh(col_pins[i]); 114 writePinHigh(col_pins[i]);
115 setPinInputHigh(col_pins[i]); 115 setPinInputHigh(col_pins[i]);
116 } 116 }
diff --git a/keyboards/ymdk/melody96/keymaps/konstantin/keymap.c b/keyboards/ymdk/melody96/keymaps/konstantin/keymap.c
index 1ee7ca1e77..cc6cbd90c2 100644
--- a/keyboards/ymdk/melody96/keymaps/konstantin/keymap.c
+++ b/keyboards/ymdk/melody96/keymaps/konstantin/keymap.c
@@ -2,7 +2,7 @@
2#include "konstantin.h" 2#include "konstantin.h"
3 3
4static const HSV *colors[] = { &godspeed_blue, &godspeed_yellow }; 4static const HSV *colors[] = { &godspeed_blue, &godspeed_yellow };
5static const size_t cnum = sizeof colors / sizeof *colors; 5static const size_t cnum = ARRAY_SIZE(colors);
6static size_t cidx = 0; 6static size_t cidx = 0;
7 7
8enum keycodes_keymap { 8enum keycodes_keymap {
diff --git a/lib/usbhost/USB_Host_Shield_2.0/SPP.cpp b/lib/usbhost/USB_Host_Shield_2.0/SPP.cpp
index 0f4ee5e981..8169707661 100644
--- a/lib/usbhost/USB_Host_Shield_2.0/SPP.cpp
+++ b/lib/usbhost/USB_Host_Shield_2.0/SPP.cpp
@@ -757,7 +757,7 @@ size_t SPP::write(const uint8_t *data, size_t size) {
757void SPP::write(const uint8_t *data, size_t size) { 757void SPP::write(const uint8_t *data, size_t size) {
758#endif 758#endif
759 for(uint8_t i = 0; i < size; i++) { 759 for(uint8_t i = 0; i < size; i++) {
760 if(sppIndex >= sizeof (sppOutputBuffer) / sizeof (sppOutputBuffer[0])) 760 if(sppIndex >= ARRAY_SIZE(sppOutputBuffer))
761 send(); // Send the current data in the buffer 761 send(); // Send the current data in the buffer
762 sppOutputBuffer[sppIndex++] = data[i]; // All the bytes are put into a buffer and then send using the send() function 762 sppOutputBuffer[sppIndex++] = data[i]; // All the bytes are put into a buffer and then send using the send() function
763 } 763 }
diff --git a/lib/usbhost/USB_Host_Shield_2.0/examples/Bluetooth/PS3Multi/PS3Multi.ino b/lib/usbhost/USB_Host_Shield_2.0/examples/Bluetooth/PS3Multi/PS3Multi.ino
index 5ebfd7819c..11833334d0 100644
--- a/lib/usbhost/USB_Host_Shield_2.0/examples/Bluetooth/PS3Multi/PS3Multi.ino
+++ b/lib/usbhost/USB_Host_Shield_2.0/examples/Bluetooth/PS3Multi/PS3Multi.ino
@@ -19,7 +19,7 @@ USB Usb;
19 19
20BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so 20BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
21PS3BT *PS3[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM! 21PS3BT *PS3[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM!
22const uint8_t length = sizeof(PS3) / sizeof(PS3[0]); // Get the lenght of the array 22const uint8_t length = ARRAY_SIZE(PS3); // Get the lenght of the array
23bool printAngle[length]; 23bool printAngle[length];
24bool oldControllerState[length]; 24bool oldControllerState[length];
25 25
diff --git a/lib/usbhost/USB_Host_Shield_2.0/examples/Bluetooth/WiiMulti/WiiMulti.ino b/lib/usbhost/USB_Host_Shield_2.0/examples/Bluetooth/WiiMulti/WiiMulti.ino
index 07c6f13d2b..93cd084651 100644
--- a/lib/usbhost/USB_Host_Shield_2.0/examples/Bluetooth/WiiMulti/WiiMulti.ino
+++ b/lib/usbhost/USB_Host_Shield_2.0/examples/Bluetooth/WiiMulti/WiiMulti.ino
@@ -19,7 +19,7 @@ USB Usb;
19 19
20BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so 20BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
21WII *Wii[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM! 21WII *Wii[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM!
22const uint8_t length = sizeof(Wii) / sizeof(Wii[0]); // Get the lenght of the array 22const uint8_t length = ARRAY_SIZE(Wii); // Get the lenght of the array
23bool printAngle[length]; 23bool printAngle[length];
24bool oldControllerState[length]; 24bool oldControllerState[length];
25 25
diff --git a/lib/usbhost/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.h b/lib/usbhost/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.h
index 2400364e65..05dab14afe 100644
--- a/lib/usbhost/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.h
+++ b/lib/usbhost/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.h
@@ -25,7 +25,7 @@ public:
25 virtual void OnGamePadChanged(const GamePadEventData *evt); 25 virtual void OnGamePadChanged(const GamePadEventData *evt);
26}; 26};
27 27
28#define RPT_GAMEPAD_LEN sizeof(GamePadEventData)/sizeof(uint8_t) 28#define RPT_GAMEPAD_LEN sizeof(GamePadEventData)
29 29
30class JoystickReportParser : public HIDReportParser 30class JoystickReportParser : public HIDReportParser
31{ 31{
diff --git a/lib/usbhost/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h b/lib/usbhost/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h
index 57fbb033bf..7af18b88f7 100644
--- a/lib/usbhost/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h
+++ b/lib/usbhost/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h
@@ -38,7 +38,7 @@ public:
38 virtual void OnScaleChanged(const ScaleEventData *evt); 38 virtual void OnScaleChanged(const ScaleEventData *evt);
39}; 39};
40 40
41#define RPT_SCALE_LEN sizeof(ScaleEventData)/sizeof(uint8_t) 41#define RPT_SCALE_LEN sizeof(ScaleEventData)
42 42
43class ScaleReportParser : public HIDReportParser 43class ScaleReportParser : public HIDReportParser
44{ 44{
diff --git a/platforms/chibios/drivers/ws2812_spi.c b/platforms/chibios/drivers/ws2812_spi.c
index a73eb69720..390884a2a4 100644
--- a/platforms/chibios/drivers/ws2812_spi.c
+++ b/platforms/chibios/drivers/ws2812_spi.c
@@ -181,7 +181,7 @@ void ws2812_init(void) {
181 spiStart(&WS2812_SPI, &spicfg); /* Setup transfer parameters. */ 181 spiStart(&WS2812_SPI, &spicfg); /* Setup transfer parameters. */
182 spiSelect(&WS2812_SPI); /* Slave Select assertion. */ 182 spiSelect(&WS2812_SPI); /* Slave Select assertion. */
183#ifdef WS2812_SPI_USE_CIRCULAR_BUFFER 183#ifdef WS2812_SPI_USE_CIRCULAR_BUFFER
184 spiStartSend(&WS2812_SPI, sizeof(txbuf) / sizeof(txbuf[0]), txbuf); 184 spiStartSend(&WS2812_SPI, ARRAY_SIZE(txbuf), txbuf);
185#endif 185#endif
186} 186}
187 187
@@ -200,9 +200,9 @@ void ws2812_setleds(LED_TYPE* ledarray, uint16_t leds) {
200 // Instead spiSend can be used to send synchronously (or the thread logic can be added back). 200 // Instead spiSend can be used to send synchronously (or the thread logic can be added back).
201#ifndef WS2812_SPI_USE_CIRCULAR_BUFFER 201#ifndef WS2812_SPI_USE_CIRCULAR_BUFFER
202# ifdef WS2812_SPI_SYNC 202# ifdef WS2812_SPI_SYNC
203 spiSend(&WS2812_SPI, sizeof(txbuf) / sizeof(txbuf[0]), txbuf); 203 spiSend(&WS2812_SPI, ARRAY_SIZE(txbuf), txbuf);
204# else 204# else
205 spiStartSend(&WS2812_SPI, sizeof(txbuf) / sizeof(txbuf[0]), txbuf); 205 spiStartSend(&WS2812_SPI, ARRAY_SIZE(txbuf), txbuf);
206# endif 206# endif
207#endif 207#endif
208} 208}
diff --git a/quantum/backlight/backlight_driver_common.c b/quantum/backlight/backlight_driver_common.c
index e4c2e90b5f..1eb8969084 100644
--- a/quantum/backlight/backlight_driver_common.c
+++ b/quantum/backlight/backlight_driver_common.c
@@ -9,7 +9,7 @@
9#if defined(BACKLIGHT_PINS) 9#if defined(BACKLIGHT_PINS)
10static const pin_t backlight_pins[] = BACKLIGHT_PINS; 10static const pin_t backlight_pins[] = BACKLIGHT_PINS;
11# ifndef BACKLIGHT_LED_COUNT 11# ifndef BACKLIGHT_LED_COUNT
12# define BACKLIGHT_LED_COUNT (sizeof(backlight_pins) / sizeof(pin_t)) 12# define BACKLIGHT_LED_COUNT ARRAY_SIZE(backlight_pins)
13# endif 13# endif
14 14
15# define FOR_EACH_LED(x) \ 15# define FOR_EACH_LED(x) \
diff --git a/quantum/backlight/backlight_software.c b/quantum/backlight/backlight_software.c
index 3d412cab52..27ccbd2c9f 100644
--- a/quantum/backlight/backlight_software.c
+++ b/quantum/backlight/backlight_software.c
@@ -26,7 +26,7 @@ static const uint16_t backlight_duty_table[] = {
26 0b1110111011101110, 26 0b1110111011101110,
27 0b1111111111111111, 27 0b1111111111111111,
28}; 28};
29#define backlight_duty_table_size (sizeof(backlight_duty_table) / sizeof(backlight_duty_table[0])) 29#define backlight_duty_table_size ARRAY_SIZE(backlight_duty_table)
30 30
31// clang-format on 31// clang-format on
32 32
diff --git a/quantum/dip_switch.c b/quantum/dip_switch.c
index eee29aaf91..e180cfccdf 100644
--- a/quantum/dip_switch.c
+++ b/quantum/dip_switch.c
@@ -33,7 +33,7 @@
33#endif 33#endif
34 34
35#ifdef DIP_SWITCH_PINS 35#ifdef DIP_SWITCH_PINS
36# define NUMBER_OF_DIP_SWITCHES (sizeof(dip_switch_pad) / sizeof(pin_t)) 36# define NUMBER_OF_DIP_SWITCHES (ARRAY_SIZE(dip_switch_pad))
37static pin_t dip_switch_pad[] = DIP_SWITCH_PINS; 37static pin_t dip_switch_pad[] = DIP_SWITCH_PINS;
38#endif 38#endif
39 39
@@ -43,7 +43,7 @@ typedef struct matrix_index_t {
43 uint8_t col; 43 uint8_t col;
44} matrix_index_t; 44} matrix_index_t;
45 45
46# define NUMBER_OF_DIP_SWITCHES (sizeof(dip_switch_pad) / sizeof(matrix_index_t)) 46# define NUMBER_OF_DIP_SWITCHES (ARRAY_SIZE(dip_switch_pad))
47static matrix_index_t dip_switch_pad[] = DIP_SWITCH_MATRIX_GRID; 47static matrix_index_t dip_switch_pad[] = DIP_SWITCH_MATRIX_GRID;
48extern bool peek_matrix(uint8_t row_index, uint8_t col_index, bool read_raw); 48extern bool peek_matrix(uint8_t row_index, uint8_t col_index, bool read_raw);
49static uint16_t scan_count; 49static uint16_t scan_count;
diff --git a/quantum/encoder.h b/quantum/encoder.h
index 82f95b4931..4eb67fa25d 100644
--- a/quantum/encoder.h
+++ b/quantum/encoder.h
@@ -32,17 +32,17 @@ void encoder_state_raw(uint8_t* slave_state);
32void encoder_update_raw(uint8_t* slave_state); 32void encoder_update_raw(uint8_t* slave_state);
33 33
34# if defined(ENCODERS_PAD_A_RIGHT) 34# if defined(ENCODERS_PAD_A_RIGHT)
35# define NUM_ENCODERS_LEFT (sizeof(((pin_t[])ENCODERS_PAD_A)) / sizeof(pin_t)) 35# define NUM_ENCODERS_LEFT ARRAY_SIZE(((pin_t[])ENCODERS_PAD_A))
36# define NUM_ENCODERS_RIGHT (sizeof(((pin_t[])ENCODERS_PAD_A_RIGHT)) / sizeof(pin_t)) 36# define NUM_ENCODERS_RIGHT ARRAY_SIZE(((pin_t[])ENCODERS_PAD_A_RIGHT))
37# else 37# else
38# define NUM_ENCODERS_LEFT (sizeof(((pin_t[])ENCODERS_PAD_A)) / sizeof(pin_t)) 38# define NUM_ENCODERS_LEFT ARRAY_SIZE(((pin_t[])ENCODERS_PAD_A))
39# define NUM_ENCODERS_RIGHT NUM_ENCODERS_LEFT 39# define NUM_ENCODERS_RIGHT NUM_ENCODERS_LEFT
40# endif 40# endif
41# define NUM_ENCODERS (NUM_ENCODERS_LEFT + NUM_ENCODERS_RIGHT) 41# define NUM_ENCODERS (NUM_ENCODERS_LEFT + NUM_ENCODERS_RIGHT)
42 42
43#else // SPLIT_KEYBOARD 43#else // SPLIT_KEYBOARD
44 44
45# define NUM_ENCODERS (sizeof(((pin_t[])ENCODERS_PAD_A)) / sizeof(pin_t)) 45# define NUM_ENCODERS ARRAY_SIZE(((pin_t[])ENCODERS_PAD_A))
46# define NUM_ENCODERS_LEFT NUM_ENCODERS 46# define NUM_ENCODERS_LEFT NUM_ENCODERS
47# define NUM_ENCODERS_RIGHT 0 47# define NUM_ENCODERS_RIGHT 0
48 48
diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c
index ae00b3227a..3593f75f0d 100644
--- a/quantum/process_keycode/process_leader.c
+++ b/quantum/process_keycode/process_leader.c
@@ -58,7 +58,7 @@ bool process_leader(uint16_t keycode, keyrecord_t *record) {
58 keycode = keycode & 0xFF; 58 keycode = keycode & 0xFF;
59 } 59 }
60# endif // LEADER_KEY_STRICT_KEY_PROCESSING 60# endif // LEADER_KEY_STRICT_KEY_PROCESSING
61 if (leader_sequence_size < (sizeof(leader_sequence) / sizeof(leader_sequence[0]))) { 61 if (leader_sequence_size < ARRAY_SIZE(leader_sequence)) {
62 leader_sequence[leader_sequence_size] = keycode; 62 leader_sequence[leader_sequence_size] = keycode;
63 leader_sequence_size++; 63 leader_sequence_size++;
64 } else { 64 } else {
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c
index 8de31c055c..1c1aab8f48 100644
--- a/quantum/process_keycode/process_unicode_common.c
+++ b/quantum/process_keycode/process_unicode_common.c
@@ -25,7 +25,7 @@ bool unicode_saved_num_lock;
25 25
26#if UNICODE_SELECTED_MODES != -1 26#if UNICODE_SELECTED_MODES != -1
27static uint8_t selected[] = {UNICODE_SELECTED_MODES}; 27static uint8_t selected[] = {UNICODE_SELECTED_MODES};
28static int8_t selected_count = sizeof selected / sizeof *selected; 28static int8_t selected_count = ARRAY_SIZE(selected);
29static int8_t selected_index; 29static int8_t selected_index;
30#endif 30#endif
31 31
diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c
index 27fa7369bf..99151e5a92 100644
--- a/quantum/rgb_matrix/rgb_matrix_drivers.c
+++ b/quantum/rgb_matrix/rgb_matrix_drivers.c
@@ -369,7 +369,7 @@ static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) {
369} 369}
370 370
371static void setled_all(uint8_t r, uint8_t g, uint8_t b) { 371static void setled_all(uint8_t r, uint8_t g, uint8_t b) {
372 for (int i = 0; i < sizeof(rgb_matrix_ws2812_array) / sizeof(rgb_matrix_ws2812_array[0]); i++) { 372 for (int i = 0; i < ARRAY_SIZE(rgb_matrix_ws2812_array); i++) {
373 setled(i, r, g, b); 373 setled(i, r, g, b);
374 } 374 }
375} 375}
diff --git a/quantum/secure.c b/quantum/secure.c
index f07f6af2cb..f2a567f31d 100644
--- a/quantum/secure.c
+++ b/quantum/secure.c
@@ -3,6 +3,7 @@
3 3
4#include "secure.h" 4#include "secure.h"
5#include "timer.h" 5#include "timer.h"
6#include "util.h"
6 7
7#ifndef SECURE_UNLOCK_TIMEOUT 8#ifndef SECURE_UNLOCK_TIMEOUT
8# define SECURE_UNLOCK_TIMEOUT 5000 9# define SECURE_UNLOCK_TIMEOUT 5000
@@ -59,7 +60,7 @@ void secure_activity_event(void) {
59 60
60void secure_keypress_event(uint8_t row, uint8_t col) { 61void secure_keypress_event(uint8_t row, uint8_t col) {
61 static const uint8_t sequence[][2] = SECURE_UNLOCK_SEQUENCE; 62 static const uint8_t sequence[][2] = SECURE_UNLOCK_SEQUENCE;
62 static const uint8_t sequence_len = sizeof(sequence) / sizeof(sequence[0]); 63 static const uint8_t sequence_len = ARRAY_SIZE(sequence);
63 64
64 static uint8_t offset = 0; 65 static uint8_t offset = 0;
65 if ((sequence[offset][0] == row) && (sequence[offset][1] == col)) { 66 if ((sequence[offset][0] == row) && (sequence[offset][1] == col)) {
diff --git a/quantum/util.h b/quantum/util.h
index 21c290013c..9c034cc404 100644
--- a/quantum/util.h
+++ b/quantum/util.h
@@ -1,19 +1,7 @@
1/* 1// Copyright 2022 Stefan Kerkmann (KarlK90)
2Copyright 2011 Jun Wako <wakojun@gmail.com> 2// Copyright 2011 Jun Wako <wakojun@gmail.com>
3 3// SPDX-License-Identifier: GPL-2.0-or-later
4This program is free software: you can redistribute it and/or modify 4
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#pragma once 5#pragma once
18 6
19#include "bitwise.h" 7#include "bitwise.h"
@@ -29,3 +17,32 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
29#if !defined(MAX) 17#if !defined(MAX)
30# define MAX(x, y) (((x) > (y)) ? (x) : (y)) 18# define MAX(x, y) (((x) > (y)) ? (x) : (y))
31#endif 19#endif
20
21#if !defined(CEILING)
22/**
23 * @brief Computes the rounded up result of a division of two integers at
24 * compile time.
25 */
26# define CEILING(dividend, divisor) (((dividend) + (divisor)-1) / (divisor))
27#endif
28
29#if !defined(IS_ARRAY)
30/**
31 * @brief Returns true if the value is an array, false if it's a pointer.
32 *
33 * This macro is ill-formed for scalars, which is OK for its intended use in
34 * ARRAY_SIZE.
35 */
36# define IS_ARRAY(value) (!__builtin_types_compatible_p(typeof((value)), typeof(&(value)[0])))
37#endif
38
39#if !defined(ARRAY_SIZE)
40/**
41 * @brief Computes the number of elements of the given array at compile time.
42 *
43 * This Macro can only be used for statically allocated arrays that have not
44 * been decayed into a pointer. This is detected at compile time, though the
45 * error message for scalar values is poor.
46 */
47# define ARRAY_SIZE(array) (__builtin_choose_expr(IS_ARRAY((array)), sizeof((array)) / sizeof((array)[0]), (void)0))
48#endif
diff --git a/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c b/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c
index 69b3ad574c..58fc4efd9c 100644
--- a/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c
+++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c
@@ -95,7 +95,7 @@ led_setup_t leds_rainbow_s[] = {
95 95
96void *led_setups[] = {leds_rainbow_s, leds_rainbow_ns, leds_teal_salmon, leds_yellow, leds_red, leds_green, leds_blue, leds_white, leds_white_with_red_stripe, leds_black_with_red_stripe, leds_off}; 96void *led_setups[] = {leds_rainbow_s, leds_rainbow_ns, leds_teal_salmon, leds_yellow, leds_red, leds_green, leds_blue, leds_white, leds_white_with_red_stripe, leds_black_with_red_stripe, leds_off};
97 97
98const uint8_t led_setups_count = sizeof(led_setups) / sizeof(led_setups[0]); 98const uint8_t led_setups_count = ARRAY_SIZE(led_setups);
99 99
100# endif // USE_MASSDROP_CONFIGURATOR 100# endif // USE_MASSDROP_CONFIGURATOR
101#endif // RGB_MATRIX_ENABLE \ No newline at end of file 101#endif // RGB_MATRIX_ENABLE \ No newline at end of file
diff --git a/users/brandonschlack/rgb_bs.c b/users/brandonschlack/rgb_bs.c
index 1abf785b49..94842021cd 100644
--- a/users/brandonschlack/rgb_bs.c
+++ b/users/brandonschlack/rgb_bs.c
@@ -75,7 +75,7 @@ void rgb_theme_step_reverse(void) {
75 75
76rgb_theme_color_t get_rgb_theme_color(uint8_t index) { 76rgb_theme_color_t get_rgb_theme_color(uint8_t index) {
77 rgb_theme_t theme = get_rgb_theme(); 77 rgb_theme_t theme = get_rgb_theme();
78 size_t rgb_theme_color_max = sizeof theme.colors / sizeof *theme.colors; 78 size_t rgb_theme_color_max = ARRAY_SIZE(theme.colors);
79 79
80 if (index == _ADJUST) { 80 if (index == _ADJUST) {
81 return default_adjust; 81 return default_adjust;
diff --git a/users/curry/oled.c b/users/curry/oled.c
index 5a8f0de61d..89112af121 100644
--- a/users/curry/oled.c
+++ b/users/curry/oled.c
@@ -41,7 +41,7 @@ void add_keylog(uint16_t keycode) {
41 keylog_str[i] = keylog_str[i - 1]; 41 keylog_str[i] = keylog_str[i - 1];
42 } 42 }
43 43
44 if (keycode < (sizeof(code_to_name) / sizeof(char))) { 44 if (keycode < ARRAY_SIZE(code_to_name)) {
45 keylog_str[0] = pgm_read_byte(&code_to_name[keycode]); 45 keylog_str[0] = pgm_read_byte(&code_to_name[keycode]);
46 } 46 }
47 47
diff --git a/users/davidkristoffersen/util/functions.c b/users/davidkristoffersen/util/functions.c
index 781d8f214d..3ab4ace2d6 100644
--- a/users/davidkristoffersen/util/functions.c
+++ b/users/davidkristoffersen/util/functions.c
@@ -33,14 +33,14 @@ code_set_t EN_SHIFT_CODES [] = {
33const shift_code_t SHIFT_CODES [] = { 33const shift_code_t SHIFT_CODES [] = {
34#ifdef LAYER_NO 34#ifdef LAYER_NO
35 {.lang = LAYER_NO, 35 {.lang = LAYER_NO,
36 .size = ARR_LEN(NO_SHIFT_CODES), 36 .size = ARRAY_SIZE(NO_SHIFT_CODES),
37 .codes = NO_SHIFT_CODES}, 37 .codes = NO_SHIFT_CODES},
38#endif 38#endif
39 {.lang = LAYER_EN, 39 {.lang = LAYER_EN,
40 .size = ARR_LEN(EN_SHIFT_CODES), 40 .size = ARRAY_SIZE(EN_SHIFT_CODES),
41 .codes = EN_SHIFT_CODES}, 41 .codes = EN_SHIFT_CODES},
42}; 42};
43const int SHIFT_CODES_SIZE = ARR_LEN(SHIFT_CODES); 43const int SHIFT_CODES_SIZE = ARRAY_SIZE(SHIFT_CODES);
44#endif 44#endif
45 45
46#ifdef LAYER_NO 46#ifdef LAYER_NO
@@ -72,7 +72,7 @@ const code_set_t EN2NO_CODES [] = {
72 {KC_DLR, NO_DLR}, 72 {KC_DLR, NO_DLR},
73 {KC_GRV, NO_GRV} 73 {KC_GRV, NO_GRV}
74}; 74};
75const int EN2NO_CODES_SIZE = ARR_LEN(EN2NO_CODES); 75const int EN2NO_CODES_SIZE = ARRAY_SIZE(EN2NO_CODES);
76#endif 76#endif
77 77
78// Check if layer is an active default layer 78// Check if layer is an active default layer
diff --git a/users/davidkristoffersen/util/functions.h b/users/davidkristoffersen/util/functions.h
index eee1dadc57..5fef010694 100644
--- a/users/davidkristoffersen/util/functions.h
+++ b/users/davidkristoffersen/util/functions.h
@@ -15,8 +15,6 @@
15 15
16// Return false if test equal false 16// Return false if test equal false
17#define HANDLE_FALSE(bool) if (!bool) return false; 17#define HANDLE_FALSE(bool) if (!bool) return false;
18// Generic array lenght define
19#define ARR_LEN(arr) (sizeof(arr) / sizeof(arr)[0])
20// Printf-like functionality for send_string 18// Printf-like functionality for send_string
21#define SEND_VAR(str, ...) \ 19#define SEND_VAR(str, ...) \
22 do { \ 20 do { \
diff --git a/users/drashna/keyrecords/tap_dance.md b/users/drashna/keyrecords/tap_dance.md
index 0bf67cbd5a..fef1435918 100644
--- a/users/drashna/keyrecords/tap_dance.md
+++ b/users/drashna/keyrecords/tap_dance.md
@@ -88,7 +88,7 @@ void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data) {
88 diablo_timer[diablo_keys->index].keycode = diablo_keys->keycode; 88 diablo_timer[diablo_keys->index].keycode = diablo_keys->keycode;
89 89
90 // if the tapdance is hit more than the number of elemints in the array, reset 90 // if the tapdance is hit more than the number of elemints in the array, reset
91 if (state->count >= (sizeof(diablo_times) / sizeof(uint8_t) ) ) { 91 if (state->count >= ARRAY_SIZE(diablo_times) ) {
92 diablo_timer[diablo_keys->index].key_interval = 0; 92 diablo_timer[diablo_keys->index].key_interval = 0;
93 reset_tap_dance(state); 93 reset_tap_dance(state);
94 } else { // else set the interval (tapdance count starts at 1, array starts at 0, so offset by one) 94 } else { // else set the interval (tapdance count starts at 1, array starts at 0, so offset by one)
diff --git a/users/drashna/keyrecords/tap_dances.c b/users/drashna/keyrecords/tap_dances.c
index 6caf6b6b3e..7bdea3cae3 100644
--- a/users/drashna/keyrecords/tap_dances.c
+++ b/users/drashna/keyrecords/tap_dances.c
@@ -23,7 +23,7 @@ void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data) {
23 diablo_timer[diablo_keys->index].keycode = diablo_keys->keycode; 23 diablo_timer[diablo_keys->index].keycode = diablo_keys->keycode;
24 24
25 // if the tapdance is hit more than the number of elemints in the array, reset 25 // if the tapdance is hit more than the number of elemints in the array, reset
26 if (state->count >= (sizeof(diablo_times) / sizeof(uint8_t))) { 26 if (state->count >= ARRAY_SIZE(diablo_times)) {
27 diablo_timer[diablo_keys->index].key_interval = 0; 27 diablo_timer[diablo_keys->index].key_interval = 0;
28 reset_tap_dance(state); 28 reset_tap_dance(state);
29 } else { // else set the interval (tapdance count starts at 1, array starts at 0, so offset by one) 29 } else { // else set the interval (tapdance count starts at 1, array starts at 0, so offset by one)
diff --git a/users/drashna/keyrecords/unicode.c b/users/drashna/keyrecords/unicode.c
index b3fc71cb09..bfce38f555 100644
--- a/users/drashna/keyrecords/unicode.c
+++ b/users/drashna/keyrecords/unicode.c
@@ -43,7 +43,7 @@ typedef uint32_t (*translator_function_t)(bool is_shifted, uint32_t keycode);
43 static inline uint32_t translator_name(bool is_shifted, uint32_t keycode) { \ 43 static inline uint32_t translator_name(bool is_shifted, uint32_t keycode) { \
44 static const uint32_t translation[] = {__VA_ARGS__}; \ 44 static const uint32_t translation[] = {__VA_ARGS__}; \
45 uint32_t ret = keycode; \ 45 uint32_t ret = keycode; \
46 if ((keycode - KC_A) < (sizeof(translation) / sizeof(uint32_t))) { \ 46 if ((keycode - KC_A) < ARRAY_SIZE(translation)) { \
47 ret = translation[keycode - KC_A]; \ 47 ret = translation[keycode - KC_A]; \
48 } \ 48 } \
49 return ret; \ 49 return ret; \
diff --git a/users/drashna/oled/oled_stuff.c b/users/drashna/oled/oled_stuff.c
index e082f8ab3e..68801b80a4 100644
--- a/users/drashna/oled/oled_stuff.c
+++ b/users/drashna/oled/oled_stuff.c
@@ -87,7 +87,7 @@ void add_keylog(uint16_t keycode, keyrecord_t *record) {
87 87
88 memmove(keylog_str, keylog_str + 1, OLED_KEYLOGGER_LENGTH - 1); 88 memmove(keylog_str, keylog_str + 1, OLED_KEYLOGGER_LENGTH - 1);
89 89
90 if (keycode < (sizeof(code_to_name) / sizeof(char))) { 90 if (keycode < ARRAY_SIZE(code_to_name)) {
91 keylog_str[(OLED_KEYLOGGER_LENGTH - 1)] = pgm_read_byte(&code_to_name[keycode]); 91 keylog_str[(OLED_KEYLOGGER_LENGTH - 1)] = pgm_read_byte(&code_to_name[keycode]);
92 } 92 }
93 93
diff --git a/users/gourdo1/gourdo1.h b/users/gourdo1/gourdo1.h
index ecf6eaf25d..a198fd0805 100644
--- a/users/gourdo1/gourdo1.h
+++ b/users/gourdo1/gourdo1.h
@@ -17,9 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18#pragma once 18#pragma once
19 19
20// DEFINE MACROS
21#define ARRAYSIZE(arr) sizeof(arr) / sizeof(arr[0])
22
23// LAYERS -- Note: to avoid compile problems, make sure total layers matches DYNAMIC_KEYMAP_LAYER_COUNT defined in config.h (where _COLEMAK layer is defined) 20// LAYERS -- Note: to avoid compile problems, make sure total layers matches DYNAMIC_KEYMAP_LAYER_COUNT defined in config.h (where _COLEMAK layer is defined)
24enum custom_user_layers { 21enum custom_user_layers {
25 _BASE, 22 _BASE,
diff --git a/users/jonavin/jonavin.h b/users/jonavin/jonavin.h
index ab2ce0dff2..c3e383bd3a 100644
--- a/users/jonavin/jonavin.h
+++ b/users/jonavin/jonavin.h
@@ -17,9 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18#pragma once 18#pragma once
19 19
20// DEFINE MACROS
21#define ARRAYSIZE(arr) sizeof(arr)/sizeof(arr[0])
22
23 20
24// LAYERS 21// LAYERS
25enum custom_user_layers { 22enum custom_user_layers {
diff --git a/users/spidey3/layer_rgb.c b/users/spidey3/layer_rgb.c
index c867468194..b34b91679d 100644
--- a/users/spidey3/layer_rgb.c
+++ b/users/spidey3/layer_rgb.c
@@ -97,7 +97,7 @@ const rgblight_segment_t *const PROGMEM _rgb_layers[] = {
97 97
98// clang-format on 98// clang-format on
99 99
100const uint8_t PROGMEM _n_rgb_layers = sizeof(_rgb_layers) / sizeof(_rgb_layers[0]) - 1; 100const uint8_t PROGMEM _n_rgb_layers = ARRAY_SIZE(_rgb_layers) - 1;
101 101
102void clear_rgb_layers() { 102void clear_rgb_layers() {
103 for (uint8_t i = 0; i < _n_rgb_layers; i++) { 103 for (uint8_t i = 0; i < _n_rgb_layers; i++) {
diff --git a/users/uqs/uqs.c b/users/uqs/uqs.c
index 72284143c6..7e2d09e0f6 100644
--- a/users/uqs/uqs.c
+++ b/users/uqs/uqs.c
@@ -78,9 +78,9 @@ const rgblight_segment_t* const PROGMEM my_rgb_layers[] = {
78 my_rgb_segments[L_MOUSE], 78 my_rgb_segments[L_MOUSE],
79}; 79};
80 80
81_Static_assert(sizeof(my_rgb_layers) / sizeof(my_rgb_layers[0]) == 81_Static_assert(ARRAY_SIZE(my_rgb_layers) ==
82 sizeof(my_rgb_segments) / sizeof(my_rgb_segments[0]), 82 ARRAY_SIZE(my_rgb_segments),
83 "Number of rgb_segment definitions does not match up!"); 83 "Number of rgb_segment definitions does not match up!");
84#endif 84#endif
85 85
86#ifdef COMBO_ENABLE 86#ifdef COMBO_ENABLE
@@ -125,7 +125,7 @@ const uint16_t PROGMEM my_combos[][4] = {
125 {KC_BTN1, KC_BTN2, KC_BTN3, COMBO_END}, 125 {KC_BTN1, KC_BTN2, KC_BTN3, COMBO_END},
126}; 126};
127 127
128const uint16_t COMBO_LEN = sizeof(my_action_combos) / sizeof(my_action_combos[0]) + sizeof(my_combos) / sizeof(my_combos[0]); 128const uint16_t COMBO_LEN = ARRAY_SIZE(my_action_combos) + ARRAY_SIZE(my_combos);
129 129
130#define MY_ACTION_COMBO(ck) \ 130#define MY_ACTION_COMBO(ck) \
131 [ck] = { .keys = &(my_action_combos[ck][0]) } 131 [ck] = { .keys = &(my_action_combos[ck][0]) }
@@ -162,11 +162,11 @@ combo_t key_combos[] = {
162 MY_COMBO(14), 162 MY_COMBO(14),
163}; 163};
164 164
165_Static_assert(sizeof(key_combos) / sizeof(key_combos[0]) == 165_Static_assert(ARRAY_SIZE(key_combos) ==
166 (sizeof(my_action_combos) / sizeof(my_action_combos[0]) + sizeof(my_combos) / sizeof(my_combos[0])), 166 (ARRAY_SIZE(my_action_combos) + ARRAY_SIZE(my_combos)),
167 "Number of combo definitions does not match up!"); 167 "Number of combo definitions does not match up!");
168#else 168#else
169combo_t key_combos[sizeof(my_action_combos) / sizeof(my_action_combos[0]) + sizeof(my_combos) / sizeof(my_combos[0])]; 169combo_t key_combos[ARRAY_SIZE(my_action_combos) + ARRAY_SIZE(my_combos)];
170#endif 170#endif
171 171
172void process_combo_event(uint16_t combo_index, bool pressed) { 172void process_combo_event(uint16_t combo_index, bool pressed) {
@@ -235,10 +235,10 @@ void keyboard_post_init_user(void) {
235#endif 235#endif
236#if defined(COMBO_ENABLE) && !defined(COMBO_STATICALLY) 236#if defined(COMBO_ENABLE) && !defined(COMBO_STATICALLY)
237 uint8_t i = 0; 237 uint8_t i = 0;
238 for (; i < sizeof(my_action_combos) / sizeof(my_action_combos[0]); i++) { 238 for (; i < ARRAY_SIZE(my_action_combos); i++) {
239 key_combos[i].keys = &(my_action_combos[i][0]); 239 key_combos[i].keys = &(my_action_combos[i][0]);
240 } 240 }
241 for (uint8_t j = 0; j < sizeof(my_combos) / sizeof(my_combos[0]); j++, i++) { 241 for (uint8_t j = 0; j < ARRAY_SIZE(my_combos); j++, i++) {
242 key_combos[i].keycode = my_combos[j][0]; 242 key_combos[i].keycode = my_combos[j][0];
243 key_combos[i].keys = &(my_combos[j][1]); 243 key_combos[i].keys = &(my_combos[j][1]);
244 } 244 }