x11: make msb_pos return unsigned
authorRan Benita <ran234@gmail.com>
Sat, 8 Feb 2014 14:12:09 +0000 (16:12 +0200)
committerRan Benita <ran234@gmail.com>
Sat, 8 Feb 2014 14:12:09 +0000 (16:12 +0200)
It was initially returning -1 for all-zero arguments, but now it returns
0.

Signed-off-by: Ran Benita <ran234@gmail.com>
src/utils.h
src/x11/keymap.c

index 6affee1..878c2ac 100644 (file)
@@ -163,13 +163,13 @@ is_graph(char ch)
  * Note: this is 1-based! It's more useful this way, and returns 0 when
  * mask is all 0s.
  */
-static inline int
+static inline unsigned
 msb_pos(uint32_t mask)
 {
-    int pos = 0;
+    unsigned pos = 0;
     while (mask) {
         pos++;
-        mask >>= 1;
+        mask >>= 1u;
     }
     return pos;
 }
index 8581a79..51b0219 100644 (file)
@@ -883,7 +883,7 @@ get_indicator_names(struct xkb_keymap *keymap, xcb_connection_t *conn,
 {
     xcb_atom_t *iter = xcb_xkb_get_names_value_list_indicator_names(list);
 
-    FAIL_UNLESS(msb_pos(reply->indicators) <= (int) darray_size(keymap->leds));
+    FAIL_UNLESS(msb_pos(reply->indicators) <= darray_size(keymap->leds));
 
     for (int i = 0; i < NUM_INDICATORS; i++) {
         if (reply->indicators & (1u << i)) {