[libvirt] [PATCH v2 2/3] util: enum: Add NULL 'label' arg VIR_ENUM_IMPL calls

Michal Privoznik mprivozn at redhat.com
Tue Apr 16 09:11:12 UTC 2019


On 4/16/19 8:32 AM, Peter Krempa wrote:
> On Mon, Apr 15, 2019 at 17:26:41 -0400, Cole Robinson wrote:
>> Allow passing in a 'label' string for raising errors from
>> ToString/FromString calls. Adjust all VIR_ENUM_IMPL calls to
>> pass in NULL to disable error reporting. We will add strings at
>> a later time.
> 
> I think that rather than changing every single VIR_ENUM_IMPL you should
> rather add VIR_ENUM_IMPL_TYPE or VIR_ENUM_IMPL_MSG or something like
> that which will allow to use the type string.
> 
> That way it will also be far simpler to identify the places which need
> fixing.

Yes, that sounds like a better idea. For instance:

VIR_ENUM_IMPL_TYPE(virDomainVirt,
                    _("invalid domain type %s"),
                    VIR_DOMAIN_VIRT_LAST,
                    "none",
                    "qemu",
                    ...
);


Moreover, after all enums are converted then we can drop the _TYPE or 
_MSG suffix.

Michal




More information about the libvir-list mailing list