[PATCH 7/9] dix: silence compiler warning

Peter Hutterer peter.hutterer at who-t.net
Thu Oct 30 16:52:44 PDT 2014


inpututils.c:243:26: warning: comparison of constant 256 with expression of
type 'KeyCode' (aka 'unsigned char') is always false
[-Wtautological-constant-out-of-range-compare]
        if (modkeymap[i] >= MAP_LENGTH)
                    ~~~~~~~~~~~~ ^  ~~~~~~~~~~

MAP_LENGTH depends on MAX_BUTTONS which is somewhat arbitrarily chosen. We
don't expect this to ever change, but just in case leave the condition there
so the code is correct if we drop the number down.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 dix/inpututils.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/dix/inpututils.c b/dix/inpututils.c
index e5bcc31..5c2a32d 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -239,8 +239,10 @@ build_modmap_from_modkeymap(CARD8 *modmap, KeyCode *modkeymap,
         if (!modkeymap[i])
             continue;
 
+#if MAP_LENGTH < 256
         if (modkeymap[i] >= MAP_LENGTH)
             return BadValue;
+#endif
 
         if (modmap[modkeymap[i]])
             return BadValue;
-- 
2.1.0



More information about the xorg-devel mailing list