[PATCHv2 1/5] storage: rearrange functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



No semantic change; done so the next patch doesn't need a forward
declaration of a static function.

* src/util/virstoragefile.c (virStorageFileProbeFormatFromBuf):
Hoist earlier.
---
 src/util/virstoragefile.c | 82 +++++++++++++++++++++++------------------------
 1 file changed, 41 insertions(+), 41 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index dc28539..f2cbaa1 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -617,6 +617,47 @@ virBackingStoreIsFile(const char *backing)
 }

 static int
+virStorageFileProbeFormatFromBuf(const char *path,
+                                 unsigned char *buf,
+                                 size_t buflen)
+{
+    int format = VIR_STORAGE_FILE_RAW;
+    int i;
+    int possibleFormat = VIR_STORAGE_FILE_RAW;
+    VIR_DEBUG("path=%s", path);
+
+    /* First check file magic */
+    for (i = 0 ; i < VIR_STORAGE_FILE_LAST ; i++) {
+        if (virStorageFileMatchesMagic(i, buf, buflen)) {
+            if (!virStorageFileMatchesVersion(i, buf, buflen)) {
+                possibleFormat = i;
+                continue;
+            }
+            format = i;
+            goto cleanup;
+        }
+    }
+
+    if (possibleFormat != VIR_STORAGE_FILE_RAW)
+        VIR_WARN("File %s matches %s magic, but version is wrong. "
+                 "Please report new version to libvir-list@xxxxxxxxxx",
+                 path, virStorageFileFormatTypeToString(possibleFormat));
+
+    /* No magic, so check file extension */
+    for (i = 0 ; i < VIR_STORAGE_FILE_LAST ; i++) {
+        if (virStorageFileMatchesExtension(i, path)) {
+            format = i;
+            goto cleanup;
+        }
+    }
+
+cleanup:
+    VIR_DEBUG("format=%d", format);
+    return format;
+}
+
+
+static int
 virStorageFileGetMetadataFromBuf(int format,
                                  const char *path,
                                  unsigned char *buf,
@@ -707,47 +748,6 @@ virStorageFileGetMetadataFromBuf(int format,
 }


-static int
-virStorageFileProbeFormatFromBuf(const char *path,
-                                 unsigned char *buf,
-                                 size_t buflen)
-{
-    int format = VIR_STORAGE_FILE_RAW;
-    int i;
-    int possibleFormat = VIR_STORAGE_FILE_RAW;
-    VIR_DEBUG("path=%s", path);
-
-    /* First check file magic */
-    for (i = 0 ; i < VIR_STORAGE_FILE_LAST ; i++) {
-        if (virStorageFileMatchesMagic(i, buf, buflen)) {
-            if (!virStorageFileMatchesVersion(i, buf, buflen)) {
-                possibleFormat = i;
-                continue;
-            }
-            format = i;
-            goto cleanup;
-        }
-    }
-
-    if (possibleFormat != VIR_STORAGE_FILE_RAW)
-        VIR_WARN("File %s matches %s magic, but version is wrong. "
-                 "Please report new version to libvir-list@xxxxxxxxxx",
-                 path, virStorageFileFormatTypeToString(possibleFormat));
-
-    /* No magic, so check file extension */
-    for (i = 0 ; i < VIR_STORAGE_FILE_LAST ; i++) {
-        if (virStorageFileMatchesExtension(i, path)) {
-            format = i;
-            goto cleanup;
-        }
-    }
-
-cleanup:
-    VIR_DEBUG("format=%d", format);
-    return format;
-}
-
-
 /**
  * virStorageFileProbeFormatFromFD:
  *
-- 
1.8.1.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]