Skip to content

Commit

Permalink
Manually use ARRAY_SIZE
Browse files Browse the repository at this point in the history
hs_set is expected to be the same size as uint16_t, though it's made
of two 8-bit integers
  • Loading branch information
jepler committed Aug 29, 2022
1 parent 2632fc5 commit 3fc9dd1
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion keyboards/mxss/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ hs_set layer_colors[4] = {
[2] = {.hue = 36, .sat = 255}, // Color for Layer 2
[3] = {.hue = 185, .sat = 255}, // Color for Layer 3
};
size_t lc_size = sizeof(layer_colors) / sizeof(uint16_t);
size_t lc_size = ARRAY_SIZE(layer_colors);

// Use NEW_SAFE_RANGE to define new custom keycodes in order to not overwrite the ones used for front LED control
enum custom_keycodes {
Expand Down
2 changes: 1 addition & 1 deletion keyboards/mxss/templates/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ hs_set layer_colors[4] = {
[2] = {.hue = 36, .sat = 255}, // Color for Layer 2
[3] = {.hue = 185, .sat = 255}, // Color for Layer 3
};
size_t lc_size = sizeof(layer_colors) / sizeof(uint16_t);
size_t lc_size = ARRAY_SIZE(layer_colors);

// Use NEW_SAFE_RANGE to define new custom keycodes in order to not overwrite the ones used for front LED control
enum custom_keycodes {
Expand Down
2 changes: 1 addition & 1 deletion platforms/chibios/drivers/ws2812_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void ws2812_init(void) {
spiStart(&WS2812_SPI, &spicfg); /* Setup transfer parameters. */
spiSelect(&WS2812_SPI); /* Slave Select assertion. */
#ifdef WS2812_SPI_USE_CIRCULAR_BUFFER
spiStartSend(&WS2812_SPI, sizeof(txbuf) / sizeof(txbuf[0]), txbuf);
spiStartSend(&WS2812_SPI, ARRAY_SIZE(txbuf), txbuf);
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions quantum/dip_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#endif

#ifdef DIP_SWITCH_PINS
# define NUMBER_OF_DIP_SWITCHES (sizeof(dip_switch_pad) / sizeof(pin_t))
# define NUMBER_OF_DIP_SWITCHES (ARRAY_SIZE(dip_switch_pad))
static pin_t dip_switch_pad[] = DIP_SWITCH_PINS;
#endif

Expand All @@ -43,7 +43,7 @@ typedef struct matrix_index_t {
uint8_t col;
} matrix_index_t;

# define NUMBER_OF_DIP_SWITCHES (sizeof(dip_switch_pad) / sizeof(matrix_index_t))
# define NUMBER_OF_DIP_SWITCHES (ARRAY_SIZE(dip_switch_pad))
static matrix_index_t dip_switch_pad[] = DIP_SWITCH_MATRIX_GRID;
extern bool peek_matrix(uint8_t row_index, uint8_t col_index, bool read_raw);
static uint16_t scan_count;
Expand Down
2 changes: 1 addition & 1 deletion users/drashna/keyrecords/tap_dance.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data) {
diablo_timer[diablo_keys->index].keycode = diablo_keys->keycode;
// if the tapdance is hit more than the number of elemints in the array, reset
if (state->count >= (sizeof(diablo_times) / sizeof(uint8_t) ) ) {
if (state->count >= ARRAY_SIZE(diablo_times) ) {
diablo_timer[diablo_keys->index].key_interval = 0;
reset_tap_dance(state);
} else { // else set the interval (tapdance count starts at 1, array starts at 0, so offset by one)
Expand Down

0 comments on commit 3fc9dd1

Please sign in to comment.