[RFC PATCH 6/7] testQEMUSchemaValidateDeprecated: Move to the top

Peter Krempa pkrempa at redhat.com
Mon Sep 20 13:49:37 UTC 2021


Move the function to the top of the file so other functions placed
towards the top will be able to reuse it.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 tests/testutilsqemuschema.c | 82 ++++++++++++++++++-------------------
 1 file changed, 41 insertions(+), 41 deletions(-)

diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c
index 7398c73ccc..38dd0e14bc 100644
--- a/tests/testutilsqemuschema.c
+++ b/tests/testutilsqemuschema.c
@@ -28,6 +28,47 @@ struct testQEMUSchemaValidateCtxt {
 };


+static int
+testQEMUSchemaValidateDeprecated(virJSONValue *root,
+                                 const char *name,
+                                 struct testQEMUSchemaValidateCtxt *ctxt)
+{
+    virJSONValue *features = virJSONValueObjectGetArray(root, "features");
+    size_t nfeatures;
+    size_t i;
+
+    if (!features)
+        return 0;
+
+    nfeatures = virJSONValueArraySize(features);
+
+    for (i = 0; i < nfeatures; i++) {
+        virJSONValue *cur = virJSONValueArrayGet(features, i);
+        const char *curstr;
+
+        if (!cur ||
+            !(curstr = virJSONValueGetString(cur))) {
+            virBufferAsprintf(ctxt->debug, "ERROR: features of '%s' are malformed", name);
+            return -2;
+        }
+
+        if (STREQ(curstr, "deprecated")) {
+            if (ctxt->allowDeprecated) {
+                virBufferAsprintf(ctxt->debug, "WARNING: '%s' is deprecated", name);
+                if (virTestGetVerbose())
+                    g_fprintf(stderr, "\nWARNING: '%s' is deprecated\n", name);
+                return 0;
+            } else {
+                virBufferAsprintf(ctxt->debug, "ERROR: '%s' is deprecated", name);
+                return -1;
+            }
+        }
+    }
+
+    return 0;
+}
+
+
 static int
 testQEMUSchemaValidateRecurse(virJSONValue *obj,
                               virJSONValue *root,
@@ -461,47 +502,6 @@ testQEMUSchemaValidateAlternate(virJSONValue *obj,
 }


-static int
-testQEMUSchemaValidateDeprecated(virJSONValue *root,
-                                 const char *name,
-                                 struct testQEMUSchemaValidateCtxt *ctxt)
-{
-    virJSONValue *features = virJSONValueObjectGetArray(root, "features");
-    size_t nfeatures;
-    size_t i;
-
-    if (!features)
-        return 0;
-
-    nfeatures = virJSONValueArraySize(features);
-
-    for (i = 0; i < nfeatures; i++) {
-        virJSONValue *cur = virJSONValueArrayGet(features, i);
-        const char *curstr;
-
-        if (!cur ||
-            !(curstr = virJSONValueGetString(cur))) {
-            virBufferAsprintf(ctxt->debug, "ERROR: features of '%s' are malformed", name);
-            return -2;
-        }
-
-        if (STREQ(curstr, "deprecated")) {
-            if (ctxt->allowDeprecated) {
-                virBufferAsprintf(ctxt->debug, "WARNING: '%s' is deprecated", name);
-                if (virTestGetVerbose())
-                    g_fprintf(stderr, "\nWARNING: '%s' is deprecated\n", name);
-                return 0;
-            } else {
-                virBufferAsprintf(ctxt->debug, "ERROR: '%s' is deprecated", name);
-                return -1;
-            }
-        }
-    }
-
-    return 0;
-}
-
-
 static int
 testQEMUSchemaValidateRecurse(virJSONValue *obj,
                               virJSONValue *root,
-- 
2.31.1




More information about the libvir-list mailing list