]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
testQEMUSchemaValidateDeprecated: Move to the top
authorPeter Krempa <pkrempa@redhat.com>
Fri, 17 Sep 2021 14:37:10 +0000 (16:37 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 1 Nov 2021 16:37:15 +0000 (17:37 +0100)
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/testutilsqemuschema.c

index dfb1add90b42920ded03f914d84f30a0a03595b9..aaa0fdaea96f3fcb495557ac0ad9be5c6b68a7df 100644 (file)
@@ -29,6 +29,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,
@@ -466,47 +507,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,