[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/2] strtosz(): Use suffix macros in switch() st
From: |
Jes Sorensen |
Subject: |
Re: [Qemu-devel] [PATCH 2/2] strtosz(): Use suffix macros in switch() statement |
Date: |
Tue, 18 Jan 2011 10:22:25 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Thunderbird/3.1.7 |
On 01/18/11 10:20, Markus Armbruster wrote:
>> diff --git a/cutils.c b/cutils.c
>> index 328738c..f2c8bbd 100644
>> --- a/cutils.c
>> +++ b/cutils.c
>> @@ -324,26 +324,26 @@ ssize_t strtosz_suffix(const char *nptr, char **end,
>> const char default_suffix)
>> }
>> }
>> switch (toupper(d)) {
>> - case 'B':
>> + case STRTOSZ_DEFSUFFIX_B:
>> mul = 1;
>> if (mul_required) {
>> goto fail;
>> }
>> break;
>> - case 'K':
>> + case STRTOSZ_DEFSUFFIX_KB:
>> mul = 1 << 10;
>> break;
>> case 0:
>> if (mul_required) {
>> goto fail;
>> }
>> - case 'M':
>> + case STRTOSZ_DEFSUFFIX_MB:
>> mul = 1ULL << 20;
>> break;
>> - case 'G':
>> + case STRTOSZ_DEFSUFFIX_GB:
>> mul = 1ULL << 30;
>> break;
>> - case 'T':
>> + case STRTOSZ_DEFSUFFIX_TB:
>> mul = 1ULL << 40;
>> break;
>> default:
>
> And this improves what? Certainly not clarity.
>
> In my opinion, the STRTOSZ_DEFSUFFIX_TB are useless chaff. Chacun à son
> goût.
It cuts out lines of code, which is good, and using the macros means the
user is less likely to make a type and use a wrong character.
It's a taste issue though, I agree!
Cheers,
Jes
- [Qemu-devel] [PATCH 0/2] strtosz() more cleanups, Jes . Sorensen, 2011/01/17
- [Qemu-devel] [PATCH 1/2] strtosz(): Fix name confusion in use of modf(), Jes . Sorensen, 2011/01/17
- [Qemu-devel] [PATCH 2/2] strtosz(): Use suffix macros in switch() statement, Jes . Sorensen, 2011/01/17
- Re: [Qemu-devel] [PATCH 2/2] strtosz(): Use suffix macros in switch() statement, Markus Armbruster, 2011/01/18
- Re: [Qemu-devel] [PATCH 2/2] strtosz(): Use suffix macros in switch() statement,
Jes Sorensen <=
- Re: [Qemu-devel] [PATCH 2/2] strtosz(): Use suffix macros in switch() statement, Alex Williamson, 2011/01/18
- Re: [Qemu-devel] [PATCH 2/2] strtosz(): Use suffix macros in switch() statement, Anthony Liguori, 2011/01/18
- Re: [Qemu-devel] [PATCH 2/2] strtosz(): Use suffix macros in switch() statement, Jes Sorensen, 2011/01/18
- Re: [Qemu-devel] [PATCH 2/2] strtosz(): Use suffix macros in switch() statement, Eric Blake, 2011/01/18
- Re: [Qemu-devel] [PATCH 2/2] strtosz(): Use suffix macros in switch() statement, Anthony Liguori, 2011/01/18
- Re: [Qemu-devel] [PATCH 2/2] strtosz(): Use suffix macros in switch() statement, Jes Sorensen, 2011/01/18
- Re: [Qemu-devel] [PATCH 2/2] strtosz(): Use suffix macros in switch() statement, Anthony Liguori, 2011/01/18
- Re: [Qemu-devel] [PATCH 2/2] strtosz(): Use suffix macros in switch() statement, Jes Sorensen, 2011/01/19
[Qemu-devel] Re: [PATCH 0/2] strtosz() more cleanups, Alex Williamson, 2011/01/17