- char *units_start = NULL;
- // FIXME: Use str_to_u64() here to avoid troubles with strtoul()
- // FIXME: Besides, who promises that u64 fits in unsigned long int?
- u64 parsed = strtoul(str, &units_start, 10);
- if(str == units_start) {
- return mp_printf(pool, "Invalid value of size: '%s'.", str);
- }
-
- if(errno == EINVAL) {
- return "Error occured during parsing of size.";
- }
- if(errno == ERANGE) {
- return "Error: size value either too large or too small.";
+ const char *units_start = NULL;
+ u64 parsed;
+ const char *err = str_to_u64(&parsed, str, &units_start, 10 | STN_FLAGS);
+ if(err != NULL) {
+ return mp_printf(pool, "Invalid value of size: '%s'; number parser error: %s.", str, err);