domaincapstest: Restructure code to avoid disabling of warnings

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>
This commit is contained in:
Peter Krempa 2023-03-08 13:29:00 +01:00
parent a4d222644e
commit e1633a1b27

View 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.") ||