mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
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:
parent
8ac4df40cc
commit
3904e6bf04
3 changed files with 348 additions and 0 deletions
|
@ -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:
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue