diff options
| author | Eric Blake <eblake@redhat.com> | 2023-05-22 14:04:25 -0500 |
|---|---|---|
| committer | Eric Blake <eblake@redhat.com> | 2023-06-02 11:24:18 -0500 |
| commit | d326d03bcdf0751049ec0bfbe246a2e828008a13 (patch) | |
| tree | 968d2979bf61129326e0a5708890bce06acfb9b2 /util/guest-random.c | |
| parent | 3b4790d4ec1f01a1d0575bda23aa08a2061d601c (diff) | |
| download | focaccia-qemu-d326d03bcdf0751049ec0bfbe246a2e828008a13.tar.gz focaccia-qemu-d326d03bcdf0751049ec0bfbe246a2e828008a13.zip | |
test-cutils: Test integral qemu_strto* value on failures
We are inconsistent on the contents of *value after a strto* parse failure. I found the following behaviors: - parse_uint() and parse_uint_full(), which document that *value is slammed to 0 on all EINVAL failures and 0 or UINT_MAX on ERANGE failures, and has unit tests for that (note that parse_uint requires non-NULL endptr, and does not fail with EINVAL for trailing junk) - qemu_strtosz(), which leaves *value untouched on all failures (both EINVAL and ERANGE), and has unit tests but not documentation for that - qemu_strtoi() and other integral friends, which document *value on ERANGE failures but is unspecified on EINVAL (other than implicitly by comparison to libc strto*); there, *value is untouched for NULL string, slammed to 0 on no conversion, and left at the prefix value on NULL endptr; unit tests do not consistently check the value - qemu_strtod(), which documents *value on ERANGE failures but is unspecified on EINVAL; there, *value is untouched for NULL string, slammed to 0.0 for no conversion, and left at the prefix value on NULL endptr; there are no unit tests (other than indirectly through qemu_strtosz) - qemu_strtod_finite(), which documents *value on ERANGE failures but is unspecified on EINVAL; there, *value is left at the prefix for 'inf' or 'nan' and untouched in all other cases; there are no unit tests (other than indirectly through qemu_strtosz) Upcoming patches will change behaviors for consistency, but it's best to first have more unit test coverage to see the impact of those changes. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Hanna Czenczek <hreitz@redhat.com> Message-Id: <20230522190441.64278-4-eblake@redhat.com>
Diffstat (limited to 'util/guest-random.c')
0 files changed, 0 insertions, 0 deletions