On Tue, Oct 23, 2018 at 05:23:00PM +0200, David Hildenbrand wrote: > The qemu api claims to be easier to use, and the resulting code seems to > agree. > > Signed-off-by: David Hildenbrand <da...@redhat.com>
Reviewed-by: David Gibson <da...@gibson.dropbear.id.au> > --- > qapi/string-input-visitor.c | 17 ++++++----------- > 1 file changed, 6 insertions(+), 11 deletions(-) > > diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c > index b3fdd0827d..c1454f999f 100644 > --- a/qapi/string-input-visitor.c > +++ b/qapi/string-input-visitor.c > @@ -20,6 +20,7 @@ > #include "qemu/option.h" > #include "qemu/queue.h" > #include "qemu/range.h" > +#include "qemu/cutils.h" > > > struct StringInputVisitor > @@ -46,10 +47,10 @@ static void free_range(void *range, void *dummy) > > static int parse_str(StringInputVisitor *siv, const char *name, Error **errp) > { > - char *str = (char *) siv->string; > - long long start, end; > + const char *str = (char *) siv->string; > + const char *endptr; > + int64_t start, end; > Range *cur; > - char *endptr; > > if (siv->ranges) { > return 0; > @@ -60,9 +61,7 @@ static int parse_str(StringInputVisitor *siv, const char > *name, Error **errp) > } > > do { > - errno = 0; > - start = strtoll(str, &endptr, 0); > - if (errno == 0 && endptr > str) { > + if (!qemu_strtoi64(str, &endptr, 0, &start)) { > if (*endptr == '\0') { > cur = g_malloc0(sizeof(*cur)); > range_set_bounds(cur, start, start); > @@ -71,11 +70,7 @@ static int parse_str(StringInputVisitor *siv, const char > *name, Error **errp) > str = NULL; > } else if (*endptr == '-') { > str = endptr + 1; > - errno = 0; > - end = strtoll(str, &endptr, 0); > - if (errno == 0 && endptr > str && start <= end && > - (start > INT64_MAX - 65536 || > - end < start + 65536)) { > + if (!qemu_strtoi64(str, &endptr, 0, &end) && start < end) { > if (*endptr == '\0') { > cur = g_malloc0(sizeof(*cur)); > range_set_bounds(cur, start, end); -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature