Remove keycode_range_is_legal It was a pretty pointless check. Also sanitise the _x11 variant to actually do what it says on the box. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
diff --git a/include/xkbcommon/xkbcommon.h b/include/xkbcommon/xkbcommon.h
index 597948e..8ecb388 100644
--- a/include/xkbcommon/xkbcommon.h
+++ b/include/xkbcommon/xkbcommon.h
@@ -101,12 +101,7 @@ typedef uint32_t xkb_led_index_t;
#define XKB_KEYCODE_MAX (0xffffffff - 1)
#define xkb_keycode_is_legal_ext(kc) (kc <= XKB_KEYCODE_MAX)
-#define xkb_keycode_is_legal_x11(kc) (kc <= XKB_KEYCODE_MAX)
-#define xkb_keymap_keycode_range_is_legal(xkb) \
- (xkb->max_key_code > 0 && \
- xkb->max_key_code > xkb->min_key_code && \
- xkb_keycode_is_legal_ext(xkb->min_key_code) && \
- xkb_keycode_is_legal_ext(xkb->max_key_code))
+#define xkb_keycode_is_legal_x11(kc) (kc >= 8 && kc <= 255)
/**
* Names to compile a keymap with, also known as RMLVO. These names together
diff --git a/src/alloc.c b/src/alloc.c
index 09bba46..b4668ff 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -35,15 +35,6 @@ XkbcAllocClientMap(struct xkb_keymap *keymap, unsigned which,
if (!keymap || ((nTotalTypes > 0) && (nTotalTypes < XkbNumRequiredTypes)))
return BadValue;
- if ((which & XkbKeySymsMask) &&
- !xkb_keymap_keycode_range_is_legal(keymap)) {
-#ifdef DEBUG
- fprintf(stderr, "bad keycode (%d,%d) in XkbAllocClientMap\n",
- keymap->min_key_code, keymap->max_key_code);
-#endif
- return BadValue;
- }
-
if (!keymap->map) {
map = uTypedCalloc(1, struct xkb_client_map);
if (!map)
@@ -126,9 +117,6 @@ XkbcAllocServerMap(struct xkb_keymap *keymap, unsigned which,
if (!which)
return Success;
- if (!xkb_keymap_keycode_range_is_legal(keymap))
- return BadMatch;
-
if (!map->explicit) {
i = keymap->max_key_code + 1;
map->explicit = uTypedCalloc(i, unsigned char);
@@ -469,9 +457,6 @@ XkbcAllocNames(struct xkb_keymap *keymap, unsigned which,
}
if ((which & XkbKeyNamesMask) && !names->keys) {
- if (!xkb_keymap_keycode_range_is_legal(keymap))
- return BadMatch;
-
names->keys = uTypedCalloc(keymap->max_key_code + 1,
struct xkb_key_name);
if (!names->keys)