diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 180ac15a15..c7396e4361 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -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; } diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index e3b1e2813b..855e51460b 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -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; diff --git a/tests/utiltest.c b/tests/utiltest.c index 2bff7859dc..2921ae8d8c 100644 --- a/tests/utiltest.c +++ b/tests/utiltest.c @@ -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; }