xkbcomp: make a couple of casts explicit to mark them as checked
authorRan Benita <ran@unusedvar.com>
Fri, 27 Dec 2019 19:51:34 +0000 (21:51 +0200)
committerRan Benita <ran@unusedvar.com>
Fri, 27 Dec 2019 19:55:14 +0000 (21:55 +0200)
This acknowledges some "possible loss of data cast" warnings from MSVC.

Signed-off-by: Ran Benita <ran@unusedvar.com>
src/xkbcomp/keycodes.c
src/xkbcomp/scanner.c

index 4b72d05..b8abf36 100644 (file)
@@ -384,7 +384,8 @@ HandleKeycodeDef(KeyNamesInfo *info, KeycodeDef *stmt, enum merge_mode merge)
         return false;
     }
 
-    return AddKeyName(info, stmt->value, stmt->name, merge, false, true);
+    return AddKeyName(info, (xkb_keycode_t) stmt->value,
+                      stmt->name, merge, false, true);
 }
 
 static bool
index b70e5ca..65eef53 100644 (file)
@@ -50,7 +50,9 @@ number(struct scanner *s, int64_t *out, int *out_tok)
     if (is_hex)
         *out = strtoul(start, &end, 16);
     else if (is_float)
-        *out = strtod(start, &end);
+        /* The parser currently just ignores floats, so the cast is
+         * fine - the value doesn't matter. */
+        *out = (int64_t) strtod(start, &end);
     else
         *out = strtoul(start, &end, 10);
     if (errno != 0 || s->s + s->pos != end)