e3f9fe2d40
There are lots of duplicate parsing code using strto*() in QEMU, and most of that code is broken in one way or another. Even the visitors code have duplicate integer parsing code[1]. This introduces functions to help parsing unsigned int values: parse_uint() and parse_uint_full(). Parsing functions for signed ints and floats will be submitted later. parse_uint_full() has all the checks made by opts_type_uint64() at opts-visitor.c: - Check for NULL (returns -EINVAL) - Check for negative numbers (returns -EINVAL) - Check for empty string (returns -EINVAL) - Check for overflow or other errno values set by strtoll() (returns -errno) - Check for end of string (reject invalid characters after number) (returns -EINVAL) parse_uint() does everything above except checking for the end of the string, so callers can continue parsing the remainder of string after the number. Unit tests included. [1] string-input-visitor.c:parse_int() could use the same parsing code used by opts-visitor.c:opts_type_int(), instead of duplicating that logic. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> |
||
---|---|---|
.. | ||
qemu-iotests | ||
tcg | ||
.gitignore | ||
check-block.sh | ||
check-qdict.c | ||
check-qfloat.c | ||
check-qint.c | ||
check-qjson.c | ||
check-qlist.c | ||
check-qstring.c | ||
fdc-test.c | ||
hd-geo-test.c | ||
libi2c-omap.c | ||
libi2c.c | ||
libi2c.h | ||
libqtest.c | ||
libqtest.h | ||
m48t59-test.c | ||
Makefile | ||
qemu-iotests-quick.sh | ||
rtc-test.c | ||
test-aio.c | ||
test-coroutine.c | ||
test-cutils.c | ||
test-hbitmap.c | ||
test-iov.c | ||
test-qmp-commands.c | ||
test-qmp-input-strict.c | ||
test-qmp-input-visitor.c | ||
test-qmp-output-visitor.c | ||
test-string-input-visitor.c | ||
test-string-output-visitor.c | ||
test-thread-pool.c | ||
test-visitor-serialization.c | ||
test-x86-cpuid.c | ||
test-xbzrle.c | ||
tmp105-test.c |