提交 ffabad75 编写于 作者: P Peter Krempa

tests: storage: Refactor cleanup in testBackingParse

Automatically clean the temporary buffer and get rid of the cleanup
label.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 aece36f7
......@@ -609,28 +609,27 @@ static int
testBackingParse(const void *args)
{
const struct testBackingParseData *data = args;
virBuffer buf = VIR_BUFFER_INITIALIZER;
int ret = -1;
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
VIR_AUTOFREE(char *) xml = NULL;
VIR_AUTOUNREF(virStorageSourcePtr) src = NULL;
if (!(src = virStorageSourceNewFromBackingAbsolute(data->backing))) {
if (!data->expect)
ret = 0;
goto cleanup;
return 0;
else
return -1;
}
if (src && !data->expect) {
fprintf(stderr, "parsing of backing store string '%s' should "
"have failed\n", data->backing);
goto cleanup;
return -1;
}
if (virDomainDiskSourceFormat(&buf, src, "source", 0, false, 0, NULL) < 0 ||
!(xml = virBufferContentAndReset(&buf))) {
fprintf(stderr, "failed to format disk source xml\n");
goto cleanup;
return -1;
}
if (STRNEQ(xml, data->expect)) {
......@@ -638,15 +637,10 @@ testBackingParse(const void *args)
"expected storage source xml:\n%s\n"
"actual storage source xml:\n%s\n",
data->backing, data->expect, xml);
goto cleanup;
return -1;
}
ret = 0;
cleanup:
virBufferFreeAndReset(&buf);
return ret;
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册