]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: storage: Convert disk locality check to switch statement
authorPeter Krempa <pkrempa@redhat.com>
Wed, 3 Sep 2014 16:54:56 +0000 (18:54 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 10 Sep 2014 11:12:45 +0000 (13:12 +0200)
To allow the compiler to track future additions of disk types, convert
the function to use a switch statement with the correct type.

src/util/virstoragefile.c

index 5b6b2f58ecd2148f706c2a0e87a1d2cca6b7f62d..299edcd48e2282042e71efa2376b1d0faf995d58 100644 (file)
@@ -1956,7 +1956,22 @@ virStorageSourceGetActualType(virStorageSourcePtr def)
 bool
 virStorageSourceIsLocalStorage(virStorageSourcePtr src)
 {
-    return virStorageSourceGetActualType(src) != VIR_STORAGE_TYPE_NETWORK;
+    virStorageType type = virStorageSourceGetActualType(src);
+
+    switch (type) {
+    case VIR_STORAGE_TYPE_FILE:
+    case VIR_STORAGE_TYPE_BLOCK:
+    case VIR_STORAGE_TYPE_DIR:
+        return true;
+
+    case VIR_STORAGE_TYPE_NETWORK:
+    case VIR_STORAGE_TYPE_VOLUME:
+    case VIR_STORAGE_TYPE_LAST:
+    case VIR_STORAGE_TYPE_NONE:
+        return false;
+    }
+
+    return false;
 }