]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
conf: Add compile time check that devices were checked for ABI stability
authorPeter Krempa <pkrempa@redhat.com>
Mon, 29 Sep 2014 16:43:34 +0000 (18:43 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 15 Oct 2014 08:27:50 +0000 (10:27 +0200)
As in the device info iterator add a switch that will force the compiler
to check that new device types are added to the ABI stability checker.

src/conf/domain_conf.c

index 5e3c389723f5f44c44eccb1f4af01db407791134..06341167f6b597947fd36598dfd16fa638e9525e 100644 (file)
@@ -15449,6 +15449,39 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
             goto error;
     }
 
+    /* Coverity is not very happy with this - all dead_error_condition */
+#if !STATIC_ANALYSIS
+    /* This switch statement is here to trigger compiler warning when adding
+     * a new device type. When you are adding a new field to the switch you
+     * also have to add an check above. Otherwise the switch statement has no
+     * real function here and should be optimized out by the compiler. */
+    i = VIR_DOMAIN_DEVICE_LAST;
+    switch ((virDomainDeviceType) i) {
+    case VIR_DOMAIN_DEVICE_DISK:
+    case VIR_DOMAIN_DEVICE_LEASE:
+    case VIR_DOMAIN_DEVICE_FS:
+    case VIR_DOMAIN_DEVICE_NET:
+    case VIR_DOMAIN_DEVICE_INPUT:
+    case VIR_DOMAIN_DEVICE_SOUND:
+    case VIR_DOMAIN_DEVICE_VIDEO:
+    case VIR_DOMAIN_DEVICE_HOSTDEV:
+    case VIR_DOMAIN_DEVICE_WATCHDOG:
+    case VIR_DOMAIN_DEVICE_CONTROLLER:
+    case VIR_DOMAIN_DEVICE_GRAPHICS:
+    case VIR_DOMAIN_DEVICE_HUB:
+    case VIR_DOMAIN_DEVICE_REDIRDEV:
+    case VIR_DOMAIN_DEVICE_NONE:
+    case VIR_DOMAIN_DEVICE_SMARTCARD:
+    case VIR_DOMAIN_DEVICE_CHR:
+    case VIR_DOMAIN_DEVICE_MEMBALLOON:
+    case VIR_DOMAIN_DEVICE_NVRAM:
+    case VIR_DOMAIN_DEVICE_LAST:
+    case VIR_DOMAIN_DEVICE_RNG:
+    case VIR_DOMAIN_DEVICE_SHMEM:
+        break;
+    }
+#endif
+
     return true;
 
  error: