[libvirt] [PATCH v2 1/2] util: TristateBool and TristateSwitch are interchangeable

Michal Privoznik mprivozn at redhat.com
Mon Feb 22 14:36:46 UTC 2016


On 19.02.2016 15:30, Marc-André Lureau wrote:
> It may be useful in some cases to call TristateSwitch helper with TristateBool.
> Document that enum values equivalency in the code.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
> ---
>  src/util/virutil.h | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/util/virutil.h b/src/util/virutil.h
> index 535807c..b121de0 100644
> --- a/src/util/virutil.h
> +++ b/src/util/virutil.h
> @@ -236,10 +236,15 @@ typedef enum {
>      VIR_TRISTATE_SWITCH_LAST
>  } virTristateSwitch;
>  
> -
>  VIR_ENUM_DECL(virTristateBool)
>  VIR_ENUM_DECL(virTristateSwitch)
>  
> +/* the two enums must be in sync to be able to use helpers interchangeably in
> + * some special cases */
> +verify((int)VIR_TRISTATE_BOOL_YES == (int)VIR_TRISTATE_SWITCH_ON);
> +verify((int)VIR_TRISTATE_BOOL_NO == (int)VIR_TRISTATE_SWITCH_OFF);
> +verify((int)VIR_TRISTATE_BOOL_ABSENT == (int)VIR_TRISTATE_SWITCH_ABSENT);
> +
>  unsigned int virGetListenFDs(void);
>  
>  long virGetSystemPageSize(void);
> 

ACK.

I'm pushing this one as it makes perfect sense on its own.

Michal




More information about the libvir-list mailing list