File libvirt-storage-rearrange-functions.patch of Package libvirt

From d1c56acb0f97e93823aa5e012435bedc6e3e31f2 Mon Sep 17 00:00:00 2001
Message-Id: <d1c56acb0f97e93823aa5e012435bedc6e3e31f2.1373271637.git.jdenemar@redhat.com>
From: Eric Blake <eblake@redhat.com>
Date: Mon, 25 Feb 2013 16:21:49 -0700
Subject: [PATCH] storage: rearrange functions

https://bugzilla.redhat.com/show_bug.cgi?id=903248

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.
(cherry picked from commit 5e4946d4d98badb9982ff78d795e1bbd9829ccde)
---
 src/util/storage_file.c | 82 ++++++++++++++++++++++++-------------------------
 1 file changed, 41 insertions(+), 41 deletions(-)

diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index 862aa33..92c3783 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -603,6 +603,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@redhat.com",
+                 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,
@@ -693,47 +734,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@redhat.com",
-                 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.2.1

openSUSE Build Service is sponsored by