提交 fc4364a5 编写于 作者: M Michal Privoznik

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: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 f603b99a
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册