Commit 3e3ddd43e93f615bd783cde723032d14c834f474

Daniel Stone 2012-05-09T20:12:18

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>

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)