[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 11/11] cutils: Improve qemu_strtosz handling of fractions
|
From: |
Eric Blake |
|
Subject: |
Re: [PATCH 11/11] cutils: Improve qemu_strtosz handling of fractions |
|
Date: |
Mon, 8 May 2023 16:21:01 -0500 |
|
User-agent: |
NeoMutt/20230407 |
On Mon, May 08, 2023 at 03:03:43PM -0500, Eric Blake wrote:
> We have several limitations and bugs worth fixing; they are
> inter-related enough that it is not worth splitting this patch into
> smaller pieces:
>
> * ".5k" should work to specify 512, just as "0.5k" does
> * "1.9999k" and "1." + "9"*50 + "k" should both produce the same
> result of 2048 after rounding
> * "1." + "0"*350 + "1B" should not be treated the same as "1.0B";
> underflow in the fraction should not be lost
> * "7.99e99" and "7.99e999" look similar, but our code was doing a
> read-out-of-bounds on the latter because it was not expecting ERANGE
> due to overflow. While we document that scientific notation is not
> supported, and the previous patch actually fixed
> qemu_strtod_finite() to no longer return ERANGE overflows, it is
> easier to pre-filter than to try and determine after the fact if
> strtod() consumed more than we wanted. Note that this is a
> low-level semantic change (when endptr is not NULL, we can now
> successfully parse with a scale of 'E' and then report trailing
> junk, instead of failing outright with EINVAL); but an earlier
> commit already argued that this is not a high-level semantic change
> since the only caller passing in a non-NULL endptr also checks that
> the tail is whitespace-only.
>
> Fixes: https://gitlab.com/qemu-project/qemu/-/issues/1629
Also,
Fixes: cf923b78 ("utils: Improve qemu_strtosz() to have 64 bits of precision",
6.0.0)
Fixes: 7625a1ed ("utils: Use fixed-point arithmetic in qemu_strtosz", 6.0.0)
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
> tests/unit/test-cutils.c | 51 +++++++++++------------
> util/cutils.c | 89 ++++++++++++++++++++++++++++------------
> 2 files changed, 88 insertions(+), 52 deletions(-)
>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
- [PATCH 00/11] Fix qemu_strtosz() read-out-of-bounds, Eric Blake, 2023/05/08
- [PATCH 04/11] test-cutils: Add coverage of qemu_strtod, Eric Blake, 2023/05/08
- [PATCH 09/11] cutils: Set value in all integral qemu_strto* error paths, Eric Blake, 2023/05/08
- [PATCH 05/11] test-cutils: Prepare for upcoming semantic change in qemu_strtosz, Eric Blake, 2023/05/08
- [PATCH 08/11] cutils: Set value in all qemu_strtosz* error paths, Eric Blake, 2023/05/08
- [PATCH 11/11] cutils: Improve qemu_strtosz handling of fractions, Eric Blake, 2023/05/08
[PATCH 02/11] test-cutils: Use g_assert_cmpuint where appropriate, Eric Blake, 2023/05/08
[PATCH 01/11] test-cutils: Avoid g_assert in unit tests, Eric Blake, 2023/05/08
[PATCH 07/11] numa: Check for qemu_strtosz_MiB error, Eric Blake, 2023/05/08
[PATCH 03/11] test-cutils: Test integral qemu_strto* value on failures, Eric Blake, 2023/05/08
[PATCH 06/11] test-cutils: Add more coverage to qemu_strtosz, Eric Blake, 2023/05/08