Re: [PATCH RFC 0/2] util: Add VIR_ENUM_IMPL_LABEL

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

 



On 07/26/2018 07:49 PM, Cole Robinson wrote:
> This series adds VIR_ENUM_IMPL_LABEL and a demo conversion.
> 
> VIR_ENUM_IMPL_LABEL allows passing in a string that briefly
> describes the value the enum represents, which we use to
> generate error messages for FromString and ToString
> function failures.
> 
> This will allow us to drop a lot of code and unique strings
> that need translating.
> 
> Patch 2 is an example usage, converting virDomainVirtType
> enum. It's not a full conversion for this particular enum,
> just a demo. The enum creation now looks like
> 
>   VIR_ENUM_IMPL_LABEL(virDomainVirt,
>                       "domain type",
>                       VIR_DOMAIN_VIRT_LAST, ...
> 
> FromString failure reports this error for value 'zzzz'
> 
>   invalid argument: Unknown 'domain type' value 'zzzz'
> 
> ToString failure reports this error for unknown type=83
> 
>   internal error: Unknown 'domain type' internal value '83'
> 
> 
> Seems like a win to me but I'm interested in other opinions.
> This could also be a good BiteSizedTask for converting existing
> enums
> 

Agreed.

> Cole Robinson (2):
>   util: Add VIR_ENUM_IMPL_LABEL
>   conf: Convert virDomainVirtType to VIR_ENUM_IMPL_LABEL
> 
>  src/conf/domain_conf.c | 10 ++--------
>  src/util/virutil.c     | 20 ++++++++++++++++----
>  src/util/virutil.h     | 15 ++++++++++-----
>  3 files changed, 28 insertions(+), 17 deletions(-)
> 

I like this. You can count on my ACK. But we should probably let others
chime in and express their preference.

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux