testSysinfo: Use more g_auto*()

Some variables defined in the function can be freed
automatically when going out of scope. This renders @result
variable and cleanup label needless.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Michal Privoznik 2020-06-08 11:56:45 +02:00
parent f603b99ad9
commit fc4364a59a

View File

@ -47,34 +47,24 @@ struct testSysinfoData {
static int
testSysinfo(const void *data)
{
int result = -1;
const char *sysfsActualData;
virSysinfoDefPtr ret = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
g_auto(virSysinfoDefPtr) ret = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
const struct testSysinfoData *testdata = data;
virSysinfoSetup(testdata->decoder, testdata->sysinfo, testdata->cpuinfo);
if (!testdata->expected ||
!(ret = testdata->func()))
goto cleanup;
return -1;
if (virSysinfoFormat(&buf, ret) < 0)
goto cleanup;
return -1;
if (!(sysfsActualData = virBufferCurrentContent(&buf)))
goto cleanup;
return -1;
if (virTestCompareToFile(sysfsActualData, testdata->expected) < 0)
goto cleanup;
result = 0;
cleanup:
virSysinfoDefFree(ret);
virBufferFreeAndReset(&buf);
return result;
return virTestCompareToFile(sysfsActualData, testdata->expected);
}
static int