Fix up config_get_uint.

This commit is contained in:
Themaister 2012-11-26 22:11:39 +01:00
parent 710ac0031a
commit 2da456d007
1 changed files with 22 additions and 16 deletions

View File

@ -439,8 +439,8 @@ bool config_get_int(config_file_t *conf, const char *key, int *in)
*in = val; *in = val;
return true; return true;
} }
return else
false; return false;
} }
list = list->next; list = list->next;
} }
@ -462,15 +462,14 @@ bool config_get_uint64(config_file_t *conf, const char *key, uint64_t *in)
*in = val; *in = val;
return true; return true;
} }
return else
false; return false;
} }
list = list->next; list = list->next;
} }
return false; return false;
} }
bool config_get_uint(config_file_t *conf, const char *key, unsigned *in) bool config_get_uint(config_file_t *conf, const char *key, unsigned *in)
{ {
struct config_entry_list *list = conf->entries; struct config_entry_list *list = conf->entries;
@ -479,9 +478,16 @@ bool config_get_uint(config_file_t *conf, const char *key, unsigned *in)
{ {
if (strcmp(key, list->key) == 0) if (strcmp(key, list->key) == 0)
{ {
*in = strtol(list->value, NULL, 0); errno = 0;
unsigned val = strtoul(list->value, NULL, 0);
if (errno == 0)
{
*in = val;
return true; return true;
} }
else
return false;
}
list = list->next; list = list->next;
} }