[libvirt PATCH] secretxml2xmltest: refactor testCompareXMLToXMLFiles (glib chronicles)

Ján Tomko posted 1 patch 2 years, 7 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/006a4ae7b067a72d6d5365132cca17cdebb6a482.1630784519.git.jtomko@redhat.com
tests/secretxml2xmltest.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
[libvirt PATCH] secretxml2xmltest: refactor testCompareXMLToXMLFiles (glib chronicles)
Posted by Ján Tomko 2 years, 7 months ago
Use g_auto where possible and remove the pointless label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 tests/secretxml2xmltest.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/tests/secretxml2xmltest.c b/tests/secretxml2xmltest.c
index 48f48416b5..99aaa9db15 100644
--- a/tests/secretxml2xmltest.c
+++ b/tests/secretxml2xmltest.c
@@ -10,25 +10,19 @@
 static int
 testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
 {
-    char *actual = NULL;
-    int ret = -1;
-    virSecretDef *secret = NULL;
+    g_autofree char *actual = NULL;
+    g_autoptr(virSecretDef) secret = NULL;
 
     if (!(secret = virSecretDefParseFile(inxml)))
-        goto fail;
+        return -1;
 
     if (!(actual = virSecretDefFormat(secret)))
-        goto fail;
+        return -1;
 
     if (virTestCompareToFile(actual, outxml) < 0)
-        goto fail;
+        return -1;
 
-    ret = 0;
-
- fail:
-    VIR_FREE(actual);
-    virSecretDefFree(secret);
-    return ret;
+    return 0;
 }
 
 struct testInfo {
-- 
2.31.1

Re: [libvirt PATCH] secretxml2xmltest: refactor testCompareXMLToXMLFiles (glib chronicles)
Posted by Michal Prívozník 2 years, 7 months ago
On 9/4/21 9:42 PM, Ján Tomko wrote:
> Use g_auto where possible and remove the pointless label.
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>  tests/secretxml2xmltest.c | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)
> 

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal