Commit 8011d4e3 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

keys: fix signed overflow

parent 4ee185d1
...@@ -32,18 +32,19 @@ struct keysym ...@@ -32,18 +32,19 @@ struct keysym
{ {
char xname[32]; char xname[32];
char uname[64]; char uname[64];
int32_t xsym; uint32_t xsym;
int32_t usym; uint32_t usym;
}; };
static int cmpkey (const void *va, const void *vb) static int cmpkey (const void *va, const void *vb)
{ {
const struct keysym *ka = va, *kb = vb; const struct keysym *ka = va, *kb = vb;
#if (INT_MAX < 0x7fffffff) if (ka->xsym > kb->xsym)
# error Oups! return +1;
#endif if (ka->xsym < kb->xsym)
return ka->xsym - kb->xsym; return -1;
return 0;
} }
static void printkey (const void *node, const VISIT which, const int depth) static void printkey (const void *node, const VISIT which, const int depth)
...@@ -79,7 +80,7 @@ static int parse (FILE *in) ...@@ -79,7 +80,7 @@ static int parse (FILE *in)
abort (); abort ();
int val = sscanf (line, int val = sscanf (line,
"#define XK_%31s %"SCNi32" /*%*cU+%"SCNx32" %63[^*]", "#define XK_%31s %"SCNu32" /*%*cU+%"SCNx32" %63[^*]",
sym->xname, &sym->xsym, &sym->usym, sym->uname); sym->xname, &sym->xsym, &sym->usym, sym->uname);
if (val < 3) if (val < 3)
{ {
......
...@@ -386,11 +386,7 @@ static int keycmp (const void *a, const void *b) ...@@ -386,11 +386,7 @@ static int keycmp (const void *a, const void *b)
{ {
const struct mapping *ka = a, *kb = b; const struct mapping *ka = a, *kb = b;
#if (INT_MAX >= 0x7fffffff)
return ka->key - kb->key;
#else
return (ka->key < kb->key) ? -1 : (ka->key > kb->key) ? +1 : 0; return (ka->key < kb->key) ? -1 : (ka->key > kb->key) ? +1 : 0;
#endif
} }
struct vlc_actions struct vlc_actions
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment