]> xenbits.xensource.com Git - libvirt.git/commitdiff
domaincapstest: Restructure code to avoid disabling of warnings
authorPeter Krempa <pkrempa@redhat.com>
Wed, 8 Mar 2023 12:29:00 +0000 (13:29 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 3 Apr 2023 07:19:06 +0000 (09:19 +0200)
Construct the capsName/emulator strings as initialization of variable
definition and move definition of 'struct testData' above the code.

This means that 'name' field will be initialized later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/domaincapstest.c

index 2120e7efd59d748859696a057878f64d06118452..90693aac68dd0d85098733bd42bf889019f9ffae 100644 (file)
@@ -250,11 +250,20 @@ doTestQemuInternal(const char *version,
                    void *opaque)
 {
     g_autofree char *name = NULL;
-    g_autofree char *capsName = NULL;
-    g_autofree char *emulator = NULL;
+    g_autofree char *capsName = g_strdup_printf("caps_%s", version);
+    g_autofree char *emulator = g_strdup_printf("/usr/bin/qemu-system-%s", arch);
     const char *typestr = NULL;
     g_autofree char *mach = NULL;
     int rc;
+    struct testData data = {
+        .emulator = emulator,
+        .machine = machine,
+        .arch = arch,
+        .type = type,
+        .capsType = CAPS_QEMU,
+        .capsName = capsName,
+        .capsOpaque = opaque,
+    };
 
     switch ((unsigned int) type) {
     case VIR_DOMAIN_VIRT_QEMU:
@@ -275,23 +284,8 @@ doTestQemuInternal(const char *version,
     else
         mach = g_strdup("");
 
-    name = g_strdup_printf("qemu_%s%s%s.%s",
-                           version, typestr, mach, arch);
-    capsName = g_strdup_printf("caps_%s", version);
-    emulator = g_strdup_printf("/usr/bin/qemu-system-%s", arch);
-
-    VIR_WARNINGS_NO_DECLARATION_AFTER_STATEMENT
-    struct testData data = {
-        .name = name,
-        .emulator = emulator,
-        .machine = machine,
-        .arch = arch,
-        .type = type,
-        .capsType = CAPS_QEMU,
-        .capsName = capsName,
-        .capsOpaque = opaque,
-    };
-    VIR_WARNINGS_RESET
+    data.name = name = g_strdup_printf("qemu_%s%s%s.%s",
+                                       version, typestr, mach, arch);
 
     if (STRPREFIX(version, "3.") ||
         STRPREFIX(version, "4.") ||