From 9632360caa5e6511b0ec13cb4c55eb64408232b5 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 30 Aug 2022 03:20:04 -0500 Subject: 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 --- keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'keyboards/mechwild/murphpad/keymaps/jonavin') 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[] = { {"QK_BOOT", QK_BOOT}, // firmware flash mode }; -#define MAX_KEYSELECTION sizeof(keyselection)/sizeof(keyselection[0]) +#define MAX_KEYSELECTION ARRAY_SIZE(keyselection) static uint8_t selectedkey_idx = 0; static keycodedescType selectedkey_rec; -- cgit v1.2.3 From c6ff10a2577e0dcee1c8dc1ec25c84c3355d9986 Mon Sep 17 00:00:00 2001 From: jonavin <71780717+Jonavin@users.noreply.github.com> Date: Sun, 18 Sep 2022 18:57:37 -0400 Subject: FIx ARRAYSIZE def and Murphpad string array (#18392) Co-authored-by: Jonavin <=> --- keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'keyboards/mechwild/murphpad/keymaps/jonavin') diff --git a/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c b/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c index b0288c5d7a..88c017cbff 100644 --- a/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c +++ b/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c @@ -175,7 +175,7 @@ static const keycodedescType PROGMEM keyselection[] = { {"Break", KC_PAUS}, {"C-A-D", KC_CAD}, // Ctrl-Alt-Del {"AltF4", KC_AF4}, - {"QK_BOOT", QK_BOOT}, // firmware flash mode + {"RESET", QK_BOOT}, // firmware flash mode }; #define MAX_KEYSELECTION sizeof(keyselection)/sizeof(keyselection[0]) -- cgit v1.2.3 From e068f7a8d1ff3a849011cf090ce63ad1fe063e7b Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sat, 1 Oct 2022 17:47:12 +0100 Subject: RESET -> QK_BOOT user keymaps (#18560) --- keyboards/mechwild/murphpad/keymaps/jonavin/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'keyboards/mechwild/murphpad/keymaps/jonavin') diff --git a/keyboards/mechwild/murphpad/keymaps/jonavin/readme.md b/keyboards/mechwild/murphpad/keymaps/jonavin/readme.md index 0e389a5c37..ec76f0a415 100644 --- a/keyboards/mechwild/murphpad/keymaps/jonavin/readme.md +++ b/keyboards/mechwild/murphpad/keymaps/jonavin/readme.md @@ -34,7 +34,7 @@ Special Features {"Break", KC_PAUS}, {"C-A-D", KC_CAD}, // Ctrl-Alt-Del {"AltF4", KC_AF4}, - {"RESET", RESET}, // firmware flash mode + {"RESET", QK_BOOT}, // firmware flash mode }; - Additional encoder functionality -- cgit v1.2.3 From 5e4b076af3c99d36632d6b92f3ddd046f38a01af Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 16 Oct 2022 08:29:43 +1100 Subject: Remove legacy keycodes, part 5 (#18710) * `KC_SLCK` -> `KC_SCRL` * `KC_NLCK` -> `KC_NUM` --- keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c | 6 +++--- keyboards/mechwild/murphpad/keymaps/jonavin/readme.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'keyboards/mechwild/murphpad/keymaps/jonavin') diff --git a/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c b/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c index 61e98c2df8..070b572507 100644 --- a/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c +++ b/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c @@ -33,7 +33,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_BASE] = LAYOUT_landscape( TT(_FN1), TT(_FN2), KC_MUTE, - KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, KC_PPLS, KC_BSPC, + KC_NUM, KC_PSLS, KC_PAST, KC_PMNS, KC_PPLS, KC_BSPC, KC_TAB, KC_P7, KC_P8, KC_P9, KC_PDOT, KC_RGUI, KC_RSFT, KC_P4, KC_P5, KC_P6, KC_COMMA, KC_RCTL, KC_P0, KC_P1, KC_P2, KC_P3, KC_PENT, KC_RALT, @@ -44,7 +44,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, ENCFUNC, _______, KC_F10, KC_F11, KC_F12, KC_PSCR, _______, - _______, KC_F7, KC_F8, KC_F9, KC_SLCK, _______, + _______, KC_F7, KC_F8, KC_F9, KC_SCRL, _______, _______, KC_F4, KC_F5, KC_F6, KC_PAUS, _______, _______, KC_F1, KC_F2, KC_F3, _______, _______, @@ -98,7 +98,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Base */ [_BASE] = LAYOUT( TT(_FN2),TT(_FN3),TT(_FN4),LT(_RGB,KC_PSCR), - KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, + KC_NUM, KC_PSLS, KC_PAST, KC_PMNS, KC_P7, KC_P8, KC_P9, KC_PPLS, KC_MUTE, KC_P4, KC_P5, KC_P6, _______, TT(_FN1), KC_P1, KC_P2, KC_P3, KC_PENT, diff --git a/keyboards/mechwild/murphpad/keymaps/jonavin/readme.md b/keyboards/mechwild/murphpad/keymaps/jonavin/readme.md index ec76f0a415..95835343e1 100644 --- a/keyboards/mechwild/murphpad/keymaps/jonavin/readme.md +++ b/keyboards/mechwild/murphpad/keymaps/jonavin/readme.md @@ -8,7 +8,7 @@ This allows you to use Murphpad in a horizontal/landscape orientation with extra [_BASE] = LAYOUT_landscape( TT(_FN1), TT(_FN2), KC_MUTE, - KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, KC_PPLS, KC_BSPC, + KC_NUM, KC_PSLS, KC_PAST, KC_PMNS, KC_PPLS, KC_BSPC, KC_TAB, KC_P7, KC_P8, KC_P9, KC_PDOT, KC_RGUI, KC_RSFT, KC_P4, KC_P5, KC_P6, KC_COMMA, KC_RCTL, KC_P0, KC_P1, KC_P2, KC_P3, KC_PENT, KC_RALT, -- cgit v1.2.3