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 --- users/gourdo1/gourdo1.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'users/gourdo1') 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 . #pragma once -// DEFINE MACROS -#define ARRAYSIZE(arr) sizeof(arr) / sizeof(arr[0]) - // LAYERS -- Note: to avoid compile problems, make sure total layers matches DYNAMIC_KEYMAP_LAYER_COUNT defined in config.h (where _COLEMAK layer is defined) enum custom_user_layers { _BASE, -- cgit v1.2.3 From c6f1b594a2085e67219bd5f0f7ba7898429d331c Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 11 Oct 2022 06:06:26 +1100 Subject: Remove legacy keycodes, part 2 (#18660) * `KC_SYSREQ` -> `KC_SYRQ` And one `KC_ALT_ERASE` -> `KC_ERAS` * `KC_NONUS_BSLASH` -> `KC_NUBS` * `KC_NUMLOCK` -> `KC_NUM` * `KC_CLCK` -> `KC_CAPS` * `KC_SCROLLLOCK` -> `KC_SCRL` * `KC_LBRACKET` -> `KC_LBRC` * `KC_RBRACKET` -> `KC_RBRC` * `KC_CAPSLOCK` -> `KC_CAPS` --- users/gourdo1/gourdo1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'users/gourdo1') diff --git a/users/gourdo1/gourdo1.c b/users/gourdo1/gourdo1.c index 26ecd8c1c0..b724a2f48d 100644 --- a/users/gourdo1/gourdo1.c +++ b/users/gourdo1/gourdo1.c @@ -593,7 +593,7 @@ bool caps_word_press_user(uint16_t keycode) { // Turn on/off NUM LOCK if current state is different void activate_numlock(bool turn_on) { if (IS_HOST_LED_ON(USB_LED_NUM_LOCK) != turn_on) { - tap_code(KC_NUMLOCK); + tap_code(KC_NUM_LOCK); } } -- cgit v1.2.3 From 002b58f0e4ea64eb5b06e36d988160bbb907cb83 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 27 Oct 2022 21:19:16 +1100 Subject: Normalise Space Cadet keycodes (#18864) --- users/gourdo1/autocorrect/autocorrection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'users/gourdo1') diff --git a/users/gourdo1/autocorrect/autocorrection.c b/users/gourdo1/autocorrect/autocorrection.c index bc711016d9..dae62d37a2 100644 --- a/users/gourdo1/autocorrect/autocorrection.c +++ b/users/gourdo1/autocorrect/autocorrection.c @@ -71,7 +71,7 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { break; // NOTE: Space Cadet keys expose no info to check whether they are being - // tapped vs. held. This makes autocorrection ambiguous, e.g. KC_LCPO might + // tapped vs. held. This makes autocorrection ambiguous, e.g. SC_LCPO might // be '(', which we would treat as a word break, or it might be shift, which // we would treat as having no effect. To behave cautiously, we allow Space // Cadet keycodes to fall to the logic below and clear autocorrection state. -- cgit v1.2.3