qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v11 19/28] qapi: Change munging of CamelCase enu


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v11 19/28] qapi: Change munging of CamelCase enum values
Date: Wed, 11 Nov 2015 09:06:06 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 11/11/2015 07:50 AM, Markus Armbruster wrote:

>> Thankfully, only two enums are affected: ErrorClass and InputButton.

[Visiting just ErrorClass in this email]

> 
> By convention (see CODING_STYLE), we use CamelCase for type names, and
> nothing else.
> 
> Only enums violating this naming convention can be affected.  The bad
> part: they exist.
> 

> 
> ErrorClass's members are all camels.  The C enumeration constants change
> as follows
> 
>     ERROR_CLASS_GENERIC_ERROR           ERROR_CLASS_GENERICERROR
>     ERROR_CLASS_COMMAND_NOT_FOUND       ERROR_CLASS_COMMANDNOTFOUND
>     ERROR_CLASS_DEVICE_ENCRYPTED        ERROR_CLASS_DEVICEENCRYPTED
>     ERROR_CLASS_DEVICE_NOT_ACTIVE       ERROR_CLASS_DEVICENOTACTIVE
>     ERROR_CLASS_DEVICE_NOT_FOUND        ERROR_CLASS_DEVICENOTFOUND
>     ERROR_CLASS_KVM_MISSING_CAP         ERROR_CLASS_KVMMISSINGCAP
> 
> Again, not an improvement, but perhaps tolerabe, because these constants
> aren't used much anymore: 55 occurences in 20 files.
> 
> If we find it not tolerable, we can manually add aliases: rename the
> QAPI type out of the way, say 'QAPIErrorClass', then stick
> 
>     typedef enum ErrorClass {
>         ERROR_CLASS_GENERIC_ERROR = QAPI_ERROR_CLASS_GENERICERROR,
>         ERROR_CLASS_COMMAND_NOT_FOUND = QAPI_ERROR_CLASS_COMMANDNOTFOUND,
>         ERROR_CLASS_DEVICE_ENCRYPTED = QAPI_ERROR_CLASS_DEVICEENCRYPTED,
>         ERROR_CLASS_DEVICE_NOT_ACTIVE = QAPI_ERROR_CLASS_DEVICENOTACTIVE,
>         ERROR_CLASS_DEVICE_NOT_FOUND = QAPI_ERROR_CLASS_DEVICENOTFOUND,
>         ERROR_CLASS_KVM_MISSING_CAP = QAPI_ERROR_CLASS_KVMMISSINGCAP,
>     } ErrorClass;
> 
> into error.h with a suitable comment.

Interesting hack.  Certainly more legible, and I'm willing to attempt
such a rename.

As far as I'm concerned, though, this does not fix a bug, so much as
make it easier for later qapi patches to be more robust.  So any
renaming we do is not under pressure to have to make it in by 2.5.
We've got time to think about it.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]