49a1a12a327e6f78db184e83e8ea805da4477775

Author
Drashna Jaelre <drashna@live.com>
Committer
GitHub <noreply@github.com>
Date

Message

Expand count checks in keymap introspection (#24464)

* Add check Tap Dance count check to keymap introspection

* Add checks for combos and key overrides to introspection

Diff

 1diff --git a/quantum/keymap_introspection.c b/quantum/keymap_introspection.c
 2index 327df6e277b6abccd99fe3b150096faf838b4d29..236b54ce98017d7893aee13de85d8f9644e5c469 100644
 3--- a/quantum/keymap_introspection.c
 4+++ b/quantum/keymap_introspection.c
 5@@ -102,6 +102,8 @@ __attribute__((weak)) uint16_t combo_count(void) {
 6     return combo_count_raw();
 7 }
 8 
 9+_Static_assert(ARRAY_SIZE(key_combos) <= (QK_KB), "Number of combos is abnormally high. Are you using SAFE_RANGE in an enum for combos?");
10+
11 combo_t* combo_get_raw(uint16_t combo_idx) {
12     if (combo_idx >= combo_count_raw()) {
13         return NULL;
14@@ -127,6 +129,8 @@ __attribute__((weak)) uint16_t tap_dance_count(void) {
15     return tap_dance_count_raw();
16 }
17 
18+_Static_assert(ARRAY_SIZE(tap_dance_actions) <= (QK_TAP_DANCE_MAX - QK_TAP_DANCE), "Number of tap dance actions exceeds maximum. Are you using SAFE_RANGE in tap dance enum?");
19+
20 tap_dance_action_t* tap_dance_get_raw(uint16_t tap_dance_idx) {
21     if (tap_dance_idx >= tap_dance_count_raw()) {
22         return NULL;
23@@ -153,6 +157,8 @@ __attribute__((weak)) uint16_t key_override_count(void) {
24     return key_override_count_raw();
25 }
26 
27+_Static_assert(ARRAY_SIZE(key_overrides) <= (QK_KB), "Number of key overrides is abnormally high. Are you using SAFE_RANGE in an enum for key overrides?");
28+
29 const key_override_t* key_override_get_raw(uint16_t key_override_idx) {
30     if (key_override_idx >= key_override_count_raw()) {
31         return NULL;