]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: TristateBool and TristateSwitch are interchangeable
authorMarc-André Lureau <marcandre.lureau@gmail.com>
Fri, 19 Feb 2016 14:30:14 +0000 (15:30 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 22 Feb 2016 14:13:56 +0000 (15:13 +0100)
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@redhat.com>
src/util/virutil.h

index 535807c4f7a43df518189600045ac7a146365127..b121de09975f2a233f100682ee2db0e242efafe9 100644 (file)
@@ -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);