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

Re: [libvirt] [PATCH] nwfilter: Make entries in a int-2-string map more readable

On 03/30/2010 09:55 AM, Daniel P. Berrange wrote:
>> +    INTMAP_ENTRY(ETHERTYPE_IP  , "ipv4"),
>>  };
> This should all really be replaced with a standard call to VIR_ENUM_DECL + 
> VIR_ENUM_IMPL which do compile time validation that you have the correct
> number of strings to match the enum, and allow O(1) int to string conversion,
> though string to int is still O(n).

If I understand util.h right, those macros only work for enumerators
that are consecutive and which start at 0.  But Stefan is mapping
external constants, with no guarantee that they are consecutive nor that
they start at 0.  The only way to use VIR_ENUM_DECL is to write our own
wrapper enums, naming them something like VIR_ETHERTYPE_ARP; but I don't
see what it would buy us, because then we would have to convert from our
wrapper to the known external constants.

Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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