From: Ján Tomko Date: Fri, 3 Sep 2021 18:16:15 +0000 (+0200) Subject: tests: esxutils: reduce variable scope in testEscapeDatastoreItem X-Git-Tag: v7.8.0-rc1~313 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac1a9a5e8b4a146dd5bd520e8baaf2f4a9d40e4a;p=thirdparty%2Flibvirt.git tests: esxutils: reduce variable scope in testEscapeDatastoreItem Also use g_auto. Signed-off-by: Ján Tomko Reviewed-by: Pavel Hrdina --- diff --git a/tests/esxutilstest.c b/tests/esxutilstest.c index bfb35fa356..d537da3011 100644 --- a/tests/esxutilstest.c +++ b/tests/esxutilstest.c @@ -161,23 +161,19 @@ static int testEscapeDatastoreItem(const void *data G_GNUC_UNUSED) { size_t i; - char *escaped = NULL; for (i = 0; i < G_N_ELEMENTS(datastoreItems); ++i) { - VIR_FREE(escaped); + g_autofree char *escaped = NULL; escaped = esxUtil_EscapeDatastoreItem(datastoreItems[i].string); if (escaped == NULL) return -1; - if (STRNEQ(datastoreItems[i].escaped, escaped)) { - VIR_FREE(escaped); + if (STRNEQ(datastoreItems[i].escaped, escaped)) return -1; - } } - VIR_FREE(escaped); return 0; }