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

dtv: simplify/clean-up integer parsing

This works around what looks like an UBSAN bug (refs #19195).
parent 777514b4
......@@ -57,16 +57,15 @@ typedef struct
static int icmp (const void *a, const void *b)
int key = (intptr_t)a;
const int *key = a;
const dvb_int_map_t *entry = b;
return key - entry->vlc;
return *key - entry->vlc;
/** Maps a VLC config integer to a Linux DVB enum value */
static int dvb_parse_int (int i, const dvb_int_map_t *map, size_t n, int def)
const void *k = (const void *)(intptr_t)i;
const dvb_int_map_t *p = bsearch (k, map, n, sizeof (*map), icmp);
const dvb_int_map_t *p = bsearch(&i, map, n, sizeof (*map), icmp);
return (p != NULL) ? p->linux_ : def;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment