From ffabad75725f70eb35d9b7422f19122a6b5174b0 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 15 Aug 2019 19:16:21 +0200 Subject: [PATCH] tests: storage: Refactor cleanup in testBackingParse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automatically clean the temporary buffer and get rid of the cleanup label. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- tests/virstoragetest.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index f558eea622..a65491737f 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -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; } -- GitLab