spa: use strtoull for atou32

On machines with a 32 bits long, converting a negative value will
still result in  v == (uint32_t)v and the unit test will fail.
Extend to 64 bits and strtoull to reject negative values in atou32.
This commit is contained in:
Wim Taymans 2021-06-03 11:40:27 +02:00
parent 0b0a4897d6
commit 3fcb9c44ef

View file

@ -100,13 +100,13 @@ static inline bool spa_atoi32(const char *str, int32_t *val, int base)
static inline bool spa_atou32(const char *str, uint32_t *val, int base)
{
char *endptr;
unsigned long v;
unsigned long long v;
if (!str || *str =='\0')
return false;
errno = 0;
v = strtoul(str, &endptr, base);
v = strtoull(str, &endptr, base);
if (errno != 0 || *endptr != '\0')
return false;