[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [PATCH 2/5] Support human unit formats in strtobytes, e
From: |
Jes Sorensen |
Subject: |
[Qemu-devel] Re: [PATCH 2/5] Support human unit formats in strtobytes, eg. 1.0G |
Date: |
Wed, 15 Sep 2010 21:31:10 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100907 Fedora/3.1.3-1.fc13 Lightning/1.0b3pre Thunderbird/3.1.3 |
On 09/15/10 17:45, Paolo Bonzini wrote:
> On 09/15/2010 02:23 PM, address@hidden wrote:
>> switch (*endptr++) {
>> case 'K':
>> case 'k':
>> value<<= 10;
>> break;
>> case 0:
>> + if (divider) {
>> + value = 0;
>> + break;
>> + }
>> case 'M':
>> case 'm':
>> value<<= 20;
>> @@ -284,9 +306,12 @@ uint64_t strtobytes(const char *nptr, char **end)
>> default:
>> value = 0;
>> }
>> + if (divider)
>> + value /= divider;
>>
>
> This risks overflow if you do 1.00000000000000G or something similarly
> braindead. Do we loathe floating point so much that you cannot use
> strtod, like
Floating point is just plain wrong. If someone wants to do something
like in your example they really ask for an error.
Jes
- Re: [Qemu-devel] [PATCH 1/5] Introduce strtobytes() library function to convert string to byte count., (continued)
- [Qemu-devel] [PATCH 4/5] Switch migrate_set_speed() to take an 'o' argument rather than a float., Jes . Sorensen, 2010/09/15
- [Qemu-devel] [PATCH 3/5] Add support for 'o' octet (bytes) format as monitor parameter., Jes . Sorensen, 2010/09/15
- [Qemu-devel] [PATCH 5/5] Remove obsolete 'f' double parameter type, Jes . Sorensen, 2010/09/15
- [Qemu-devel] [PATCH 2/5] Support human unit formats in strtobytes, eg. 1.0G, Jes . Sorensen, 2010/09/15
- [Qemu-devel] Re: [PATCH 2/5] Support human unit formats in strtobytes, eg. 1.0G, Juan Quintela, 2010/09/15
- [Qemu-devel] Re: [PATCH 2/5] Support human unit formats in strtobytes, eg. 1.0G, Paolo Bonzini, 2010/09/15
- Re: [Qemu-devel] Re: [PATCH 2/5] Support human unit formats in strtobytes, eg. 1.0G, Anthony Liguori, 2010/09/15
- [Qemu-devel] Re: [PATCH 2/5] Support human unit formats in strtobytes, eg. 1.0G,
Jes Sorensen <=
- [Qemu-devel] Re: [PATCH 2/5] Support human unit formats in strtobytes, eg. 1.0G, Paolo Bonzini, 2010/09/16
- [Qemu-devel] Re: [PATCH 2/5] Support human unit formats in strtobytes, eg. 1.0G, Jes Sorensen, 2010/09/16
- Re: [Qemu-devel] Re: [PATCH 2/5] Support human unit formats in strtobytes, eg. 1.0G, Avi Kivity, 2010/09/16
- Re: [Qemu-devel] Re: [PATCH 2/5] Support human unit formats in strtobytes, eg. 1.0G, Jes Sorensen, 2010/09/16
- Re: [Qemu-devel] Re: [PATCH 2/5] Support human unit formats in strtobytes, eg. 1.0G, Avi Kivity, 2010/09/16
- [Qemu-devel] Re: [PATCH 2/5] Support human unit formats in strtobytes, eg. 1.0G, Paolo Bonzini, 2010/09/16