From d30548aa4810fae35977f7dcd896e9696d8d8a16 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 14 Jun 2021 16:38:26 +0200 Subject: [PATCH] testQemuMonitorJSONGetTPMModels: Refactor cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use automatic memory freeing and remove the cleanup section.t Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- tests/qemumonitorjsontest.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 5d03f83787..ab589135ba 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -560,8 +560,7 @@ testQemuMonitorJSONGetTPMModels(const void *opaque) { const testGenericData *data = opaque; virDomainXMLOption *xmlopt = data->xmlopt; - int ret = -1; - char **tpmmodels = NULL; + g_auto(GStrv) tpmmodels = NULL; int ntpmmodels = 0; g_autoptr(qemuMonitorTest) test = NULL; @@ -574,16 +573,16 @@ testQemuMonitorJSONGetTPMModels(const void *opaque) " \"passthrough\"" " ]" "}") < 0) - goto cleanup; + return -1; if ((ntpmmodels = qemuMonitorGetTPMModels(qemuMonitorTestGetMonitor(test), &tpmmodels)) < 0) - goto cleanup; + return -1; if (ntpmmodels != 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "ntpmmodels %d is not 1", ntpmmodels); - goto cleanup; + return -1; } #define CHECK(i, wantname) \ @@ -592,7 +591,7 @@ testQemuMonitorJSONGetTPMModels(const void *opaque) virReportError(VIR_ERR_INTERNAL_ERROR, \ "name %s is not %s", \ tpmmodels[i], (wantname)); \ - goto cleanup; \ + return -1; \ } \ } while (0) @@ -600,11 +599,7 @@ testQemuMonitorJSONGetTPMModels(const void *opaque) #undef CHECK - ret = 0; - - cleanup: - g_strfreev(tpmmodels); - return ret; + return 0; }