From 3904e6bf042391abc749d717465022e96e276fc7 Mon Sep 17 00:00:00 2001 From: "Carlos L. Torres" Date: Sun, 19 Jul 2015 18:02:20 -0500 Subject: cutils: Add qemu_strtoull() wrapper Add wrapper for strtoull() function. Include unit tests. Signed-off-by: Carlos L. Torres Message-Id: [Use uint64_t in prototype. - Paolo] Signed-off-by: Paolo Bonzini --- util/cutils.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'util') diff --git a/util/cutils.c b/util/cutils.c index 7084d6f1ce..67c50e5ae7 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -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: * -- cgit v1.2.3