cutils: Add qemu_strtoull() wrapper

Add wrapper for strtoull() function. Include unit tests.

Signed-off-by: Carlos L. Torres <carlos.torres@rackspace.com>
Message-Id: <e0f0f611c9a81f3c29f451d0b17d755dfab1e90a.1437346779.git.carlos.torres@rackspace.com>
[Use uint64_t in prototype. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Carlos L. Torres 2015-07-19 18:02:20 -05:00 committed by Paolo Bonzini
parent 8ac4df40cc
commit 3904e6bf04
3 changed files with 348 additions and 0 deletions

View file

@ -471,6 +471,29 @@ int qemu_strtoll(const char *nptr, const char **endptr, int base,
return err;
}
/**
* Converts ASCII string to an unsigned long long integer.
*
* See qemu_strtol() documentation for more info.
*/
int qemu_strtoull(const char *nptr, const char **endptr, int base,
uint64_t *result)
{
char *p;
int err = 0;
if (!nptr) {
if (endptr) {
*endptr = nptr;
}
err = -EINVAL;
} else {
errno = 0;
*result = strtoull(nptr, &p, base);
err = check_strtox_error(endptr, p, errno);
}
return err;
}
/**
* parse_uint:
*