mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
tests: qemu: reduce scope of some variables
Reduce the scope of some variables and mark them as g_autofree. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
63c14318ce
commit
871544520f
@ -787,7 +787,6 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test,
|
||||
virJSONValuePtr val = NULL;
|
||||
virJSONValuePtr args;
|
||||
virJSONValuePtr argobj;
|
||||
char *argstr = NULL;
|
||||
const char *cmdname;
|
||||
size_t i;
|
||||
int ret = -1;
|
||||
@ -815,6 +814,8 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test,
|
||||
/* validate the args */
|
||||
for (i = 0; i < data->nargs; i++) {
|
||||
qemuMonitorTestCommandArgsPtr arg = &data->args[i];
|
||||
g_autofree char *argstr = NULL;
|
||||
|
||||
if (!(argobj = virJSONValueObjectGet(args, arg->argname))) {
|
||||
qemuMonitorTestError("Missing argument '%s' for command '%s'",
|
||||
arg->argname,
|
||||
@ -835,15 +836,12 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test,
|
||||
arg->argval, argstr);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
VIR_FREE(argstr);
|
||||
}
|
||||
|
||||
/* arguments checked out, return the response */
|
||||
ret = qemuMonitorTestAddResponse(test, data->response);
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(argstr);
|
||||
virJSONValueFree(val);
|
||||
return ret;
|
||||
}
|
||||
|
@ -497,7 +497,6 @@ testQemuGetLatestCapsForArch(const char *arch,
|
||||
DIR *dir = NULL;
|
||||
int rc;
|
||||
char *fullsuffix = NULL;
|
||||
char *tmp = NULL;
|
||||
unsigned long maxver = 0;
|
||||
unsigned long ver;
|
||||
g_autofree char *maxname = NULL;
|
||||
@ -509,7 +508,7 @@ testQemuGetLatestCapsForArch(const char *arch,
|
||||
goto cleanup;
|
||||
|
||||
while ((rc = virDirRead(dir, &ent, TEST_QEMU_CAPS_PATH)) > 0) {
|
||||
VIR_FREE(tmp);
|
||||
g_autofree char *tmp = NULL;
|
||||
|
||||
tmp = g_strdup(STRSKIP(ent->d_name, "caps_"));
|
||||
|
||||
@ -543,7 +542,6 @@ testQemuGetLatestCapsForArch(const char *arch,
|
||||
ret = g_strdup_printf("%s/%s", TEST_QEMU_CAPS_PATH, maxname);
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(tmp);
|
||||
VIR_FREE(fullsuffix);
|
||||
virDirClose(&dir);
|
||||
return ret;
|
||||
|
@ -42,23 +42,18 @@ static int
|
||||
testIndexToDiskName(const void *data G_GNUC_UNUSED)
|
||||
{
|
||||
size_t i;
|
||||
char *diskName = NULL;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(diskNames); ++i) {
|
||||
VIR_FREE(diskName);
|
||||
g_autofree char *diskName = NULL;
|
||||
|
||||
diskName = virIndexToDiskName(i, "sd");
|
||||
|
||||
if (STRNEQ(diskNames[i], diskName)) {
|
||||
virTestDifference(stderr, diskNames[i], diskName);
|
||||
VIR_FREE(diskName);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
VIR_FREE(diskName);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -69,10 +64,9 @@ testDiskNameToIndex(const void *data G_GNUC_UNUSED)
|
||||
{
|
||||
size_t i;
|
||||
int idx;
|
||||
char *diskName = NULL;
|
||||
|
||||
for (i = 0; i < 100000; ++i) {
|
||||
VIR_FREE(diskName);
|
||||
g_autofree char *diskName = NULL;
|
||||
|
||||
diskName = virIndexToDiskName(i, "sd");
|
||||
idx = virDiskNameToIndex(diskName);
|
||||
@ -80,15 +74,10 @@ testDiskNameToIndex(const void *data G_GNUC_UNUSED)
|
||||
if (idx < 0 || idx != i) {
|
||||
VIR_TEST_DEBUG("\nExpect [%zu]", i);
|
||||
VIR_TEST_DEBUG("Actual [%d]", idx);
|
||||
|
||||
VIR_FREE(diskName);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
VIR_FREE(diskName);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user