static int64_t cvtnum(const char *s)
{
- char *end;
- int64_t ret;
+ int err;
+ uint64_t value;
- ret = qemu_strtosz(s, &end);
- if (*end != '\0') {
- /* Detritus at the end of the string */
- return -EINVAL;
+ err = qemu_strtosz(s, NULL, &value);
+ if (err < 0) {
+ return err;
}
- return ret;
+ if (value > INT64_MAX) {
+ return -ERANGE;
+ }
+ return value;
}
static void print_cvtnum_err(int64_t rc, const char *arg)