diff options
author | Carlos L. Torres <carlos.torres@rackspace.com> | 2015-07-19 18:02:20 -0500 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2015-09-09 15:34:54 +0200 |
commit | 3904e6bf042391abc749d717465022e96e276fc7 (patch) | |
tree | d405fac7b50d5b4a6c69b74ad873f8f11816eda3 /util/cutils.c | |
parent | 8ac4df40cc5de606a8ac9174e2340c21093b4e3b (diff) |
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>
Diffstat (limited to 'util/cutils.c')
-rw-r--r-- | util/cutils.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/util/cutils.c b/util/cutils.c index 7084d6f1ce..67c50e5ae7 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -472,6 +472,29 @@ int qemu_strtoll(const char *nptr, const char **endptr, int base, } /** + * 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: * * @s: String to parse |