]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage_file_probe: Move qcow2GetFeatures(ProcessGroup) functions
authorPeter Krempa <pkrempa@redhat.com>
Thu, 29 May 2025 08:12:05 +0000 (10:12 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Jun 2025 11:11:03 +0000 (13:11 +0200)
Move the two functions to where they will be used. Subsequent patches
will refactor the control flow so that they will no longer be declared
ahead of time. Moving them in a separate patch will make the changes in
the refactor more clear to see.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/storage_file/storage_file_probe.c

index 21a1013102067ec682e7246da78ce7d0bc4dff89..b357fdeb661fd504fd9f7836ce668d3b4c0b2e13 100644 (file)
@@ -573,6 +573,54 @@ qcowGetImageSpecific(virStorageSource *meta,
 }
 
 
+static void
+qcow2GetFeaturesProcessGroup(uint64_t bits,
+                             const virStorageFileFeature *featuremap,
+                             size_t nfeatures,
+                             virBitmap *features)
+{
+    size_t i;
+
+    for (i = 0; i < nfeatures; i++) {
+        if ((bits & ((uint64_t) 1 << i)) &&
+            featuremap[i] != VIR_STORAGE_FILE_FEATURE_LAST)
+            ignore_value(virBitmapSetBit(features, featuremap[i]));
+    }
+}
+
+
+static int
+qcow2GetFeatures(virBitmap **features,
+                 int format,
+                 char *buf,
+                 ssize_t len)
+{
+    int version = -1;
+
+    version = virReadBufInt32BE(buf + fileTypeInfo[format].versionOffset);
+
+    if (version == 2)
+        return 0;
+
+    if (len < QCOW2v3_HDR_SIZE)
+        return -1;
+
+    *features = virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST);
+
+    qcow2GetFeaturesProcessGroup(virReadBufInt64BE(buf + QCOW2v3_HDR_FEATURES_COMPATIBLE),
+                                 qcow2CompatibleFeatureArray,
+                                 G_N_ELEMENTS(qcow2CompatibleFeatureArray),
+                                 *features);
+
+    qcow2GetFeaturesProcessGroup(virReadBufInt64BE(buf + QCOW2v3_HDR_FEATURES_INCOMPATIBLE),
+                                 qcow2IncompatibleFeatureArray,
+                                 G_N_ELEMENTS(qcow2IncompatibleFeatureArray),
+                                 *features);
+
+    return 0;
+}
+
+
 static int
 qcow2GetImageSpecific(virStorageSource *meta,
                       const char *buf,
@@ -832,54 +880,6 @@ virStorageFileProbeFormatFromBuf(const char *path,
 }
 
 
-static void
-qcow2GetFeaturesProcessGroup(uint64_t bits,
-                             const virStorageFileFeature *featuremap,
-                             size_t nfeatures,
-                             virBitmap *features)
-{
-    size_t i;
-
-    for (i = 0; i < nfeatures; i++) {
-        if ((bits & ((uint64_t) 1 << i)) &&
-            featuremap[i] != VIR_STORAGE_FILE_FEATURE_LAST)
-            ignore_value(virBitmapSetBit(features, featuremap[i]));
-    }
-}
-
-
-static int
-qcow2GetFeatures(virBitmap **features,
-                 int format,
-                 char *buf,
-                 ssize_t len)
-{
-    int version = -1;
-
-    version = virReadBufInt32BE(buf + fileTypeInfo[format].versionOffset);
-
-    if (version == 2)
-        return 0;
-
-    if (len < QCOW2v3_HDR_SIZE)
-        return -1;
-
-    *features = virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST);
-
-    qcow2GetFeaturesProcessGroup(virReadBufInt64BE(buf + QCOW2v3_HDR_FEATURES_COMPATIBLE),
-                                 qcow2CompatibleFeatureArray,
-                                 G_N_ELEMENTS(qcow2CompatibleFeatureArray),
-                                 *features);
-
-    qcow2GetFeaturesProcessGroup(virReadBufInt64BE(buf + QCOW2v3_HDR_FEATURES_INCOMPATIBLE),
-                                 qcow2IncompatibleFeatureArray,
-                                 G_N_ELEMENTS(qcow2IncompatibleFeatureArray),
-                                 *features);
-
-    return 0;
-}
-
-
 static bool
 virStorageFileHasEncryptionFormat(const struct FileEncryptionInfo *info,
                                   char *buf,