]> xenbits.xensource.com Git - qemu-xen.git/commit
cutils: Allow NULL endptr in parse_uint()
authorEric Blake <eblake@redhat.com>
Mon, 22 May 2023 19:04:30 +0000 (14:04 -0500)
committerEric Blake <eblake@redhat.com>
Fri, 2 Jun 2023 17:29:27 +0000 (12:29 -0500)
commit52d606aa5b6859bf13b026aa82f53f8506aa6abe
tree16c667259935fca2fb4d9b3c58567f6b7f9435f7
parentbd1386cce1b184e4260721858d3bb4b4c888b5f0
cutils: Allow NULL endptr in parse_uint()

All the qemu_strto*() functions permit a NULL endptr, just like their
libc counterparts, leaving parse_uint() as the oddball that caused
SEGFAULT on NULL and required the user to call parse_uint_full()
instead.  Relax things for consistency, even though the testsuite is
the only impacted caller.  Add one more unit test to ensure even
parse_uint_full(NULL, 0, &value) works.  This also fixes our code to
uniformly favor EINVAL over ERANGE when both apply.

Also fixes a doc mismatch @v vs. a parameter named value.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
Message-Id: <20230522190441.64278-9-eblake@redhat.com>
tests/unit/test-cutils.c
util/cutils.c