]> xenbits.xensource.com Git - libvirt.git/commitdiff
Remove overengineered loop
authorJán Tomko <jtomko@redhat.com>
Fri, 10 Apr 2015 12:28:41 +0000 (14:28 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 13 Apr 2015 13:59:20 +0000 (15:59 +0200)
Do not loop over enum with one value.

src/storage/storage_backend.c

index f5b95ec7c144ca0761f1ffbe058e89af8761289b..043598367986d5d8a37c2e67596a0c41366eb9e6 100644 (file)
@@ -818,7 +818,6 @@ virStorageBackendCreateQemuImgOpts(char **opts,
                                    struct _virStorageBackendQemuImgInfo info)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
-    size_t i;
 
     if (info.backingPath)
         virBufferAsprintf(&buf, "backing_fmt=%s,",
@@ -832,28 +831,18 @@ virStorageBackendCreateQemuImgOpts(char **opts,
 
     if (info.compat)
         virBufferAsprintf(&buf, "compat=%s,", info.compat);
+
     if (info.features && info.format == VIR_STORAGE_FILE_QCOW2) {
-        for (i = 0; i < VIR_STORAGE_FILE_FEATURE_LAST; i++) {
-            if (virBitmapIsBitSet(info.features, i)) {
-                switch ((virStorageFileFeature) i) {
-                case VIR_STORAGE_FILE_FEATURE_LAZY_REFCOUNTS:
-                    if (STREQ_NULLABLE(info.compat, "0.10")) {
-                        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                                       _("Feature %s not supported with compat"
-                                         " level %s"),
-                                       virStorageFileFeatureTypeToString(i),
-                                       info.compat);
-                        goto error;
-                    }
-                    break;
-
-                /* coverity[dead_error_begin] */
-                case VIR_STORAGE_FILE_FEATURE_LAST:
-                    ;
-                }
-                virBufferAsprintf(&buf, "%s,",
-                                  virStorageFileFeatureTypeToString(i));
+        if (virBitmapIsBitSet(info.features,
+                              VIR_STORAGE_FILE_FEATURE_LAZY_REFCOUNTS)) {
+            if (STREQ_NULLABLE(info.compat, "0.10")) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("lazy_refcounts not supported with compat"
+                                 " level %s"),
+                               info.compat);
+                goto error;
             }
+            virBufferAddLit(&buf, "lazy_refcounts,");
         }
     }