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

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

 



On 03/30/2010 09:55 AM, Daniel P. Berrange wrote:
>> +    INTMAP_ENTRY(ETHERTYPE_ARP , "arp"),
>> +    INTMAP_ENTRY(ETHERTYPE_IP  , "ipv4"),
>> +    INTMAP_ENTRY(ETHERTYPE_IPV6, "ipv6"),
>> +    INTMAP_ENTRY_LAST
>>  };
> 
> 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@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
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]