virshtest: refactor testCompareOutputLit

Use g_autofree and get rid of the cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Ján Tomko 2020-02-09 02:07:19 +01:00
parent 994688e0df
commit 8bacdde9d5

View File

@ -60,26 +60,20 @@ static int
testCompareOutputLit(const char *expectData,
const char *filter, const char *const argv[])
{
int result = -1;
char *actualData = NULL;
g_autofree char *actualData = NULL;
if (virTestCaptureProgramOutput(argv, &actualData, 4096) < 0)
goto cleanup;
return -1;
if (filter && testFilterLine(actualData, filter) < 0)
goto cleanup;
return -1;
if (STRNEQ(expectData, actualData)) {
virTestDifference(stderr, expectData, actualData);
goto cleanup;
return -1;
}
result = 0;
cleanup:
VIR_FREE(actualData);
return result;
return 0;
}
# define VIRSH_DEFAULT abs_top_builddir "/tools/virsh", \