[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v17 02/14] util/cutils: Use qemu_strtold_finite to parse size
From: |
Markus Armbruster |
Subject: |
Re: [PATCH v17 02/14] util/cutils: Use qemu_strtold_finite to parse size |
Date: |
Tue, 26 Nov 2019 10:33:13 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Tao Xu <address@hidden> writes:
> On 11/25/2019 2:56 PM, Markus Armbruster wrote:
>> Tao Xu <address@hidden> writes:
>>
>>> Support full 64bit precision, modify related test cases.
>>
>> That's not true in general: long double need not be any wider than
>> double.
>>
>> It might be true on the host machines we support, but I don't know. If
>> we decide to rely on it, we better make the build fail when the host
>> machine doesn't meet our expectations, preferably in configure.
>>
> [...]
>>> - if ((val * mul >= 0xfffffffffffffc00) || val < 0) {
>>> + /* Values > UINT64_MAX overflow uint64_t */
>>> + if ((val * mul > UINT64_MAX) || val < 0) {
>>> retval = -ERANGE;
>>> goto out;
>>> }
>>
>> Not portable. If it was, we'd have made this changd long ago :)
>>
>
> OK. So the suitable solution is what you suggested in v14?
>
> "A possible alternative is to parse the numeric part both as a double
> and as a 64 bit unsigned integer, then use whatever consumes more
> characters. This enables providing full 64 bits unless you actually
> use
> a fraction."
Yes, that bypasses the portability issue.
> I will try this way.
Go ahead.
Re: [PATCH v17 03/14] util/cutils: refactor do_strtosz() to support suffixes list, Markus Armbruster, 2019/11/26
[PATCH v17 01/14] util/cutils: Add Add qemu_strtold and qemu_strtold_finite, Tao Xu, 2019/11/22