Re: [PATCHv5 1/5] domifaddr: Implement the public APIs

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

 



On 09/02/2013 03:41 AM, Nehal J Wani wrote:

> In agreement with Guido's suggestion on 5/5 of the previous version
> (https://www.redhat.com/archives/libvir-list/2013-August/msg01271.html),
> the enums are also to exposed to python bindings, for which,
> /include/libvirt/libvirt.h.in will have to be modified a bit. Diff has
> been attached.

Yes, the constants need to be exposed in python bindings.  However,


>  
>  typedef enum {
> -    VIR_IP_ADDR_TYPE_IPV4,
> -    VIR_IP_ADDR_TYPE_IPV6,
> +    VIR_IP_ADDR_TYPE_IPV4 = (1 << 0),
> +    VIR_IP_ADDR_TYPE_IPV6 = (1 << 1),

This is not the correct way to do so.  These are not bitmasks, but
should be sequential:

VIR_IP_ADDR_TYPE_IPV4 = 0,
VIR_IP_ADDR_TYPE_IPV6 = 1,

/* next one would be 2, ... */

>  
>  #ifdef VIR_ENUM_SENTINELS
> -    VIR_IP_ADDR_TYPE_LAST
> +    VIR_IP_ADDR_TYPE_LAST = (1 << 2),

and this should NOT have an explicit value (the _LAST enum is magic, and
should always be 1 more than the previous value; it is also protected
behind #ifdef because there are some contexts that should not be exposed
to the _LAST value).  I don't remember off the top of my head, but think
that python bindings are one of the places where we intentionally don't
expose _LAST values.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
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]