mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
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:
parent
f603b99ad9
commit
fc4364a59a
@ -47,34 +47,24 @@ struct testSysinfoData {
|
|||||||
static int
|
static int
|
||||||
testSysinfo(const void *data)
|
testSysinfo(const void *data)
|
||||||
{
|
{
|
||||||
int result = -1;
|
|
||||||
const char *sysfsActualData;
|
const char *sysfsActualData;
|
||||||
virSysinfoDefPtr ret = NULL;
|
g_auto(virSysinfoDefPtr) ret = NULL;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
const struct testSysinfoData *testdata = data;
|
const struct testSysinfoData *testdata = data;
|
||||||
|
|
||||||
virSysinfoSetup(testdata->decoder, testdata->sysinfo, testdata->cpuinfo);
|
virSysinfoSetup(testdata->decoder, testdata->sysinfo, testdata->cpuinfo);
|
||||||
|
|
||||||
if (!testdata->expected ||
|
if (!testdata->expected ||
|
||||||
!(ret = testdata->func()))
|
!(ret = testdata->func()))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virSysinfoFormat(&buf, ret) < 0)
|
if (virSysinfoFormat(&buf, ret) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(sysfsActualData = virBufferCurrentContent(&buf)))
|
if (!(sysfsActualData = virBufferCurrentContent(&buf)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virTestCompareToFile(sysfsActualData, testdata->expected) < 0)
|
return virTestCompareToFile(sysfsActualData, testdata->expected);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
result = 0;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virSysinfoDefFree(ret);
|
|
||||||
virBufferFreeAndReset(&buf);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user