[PATCH 04/12] util: xml: Refactor cleanup in virXMLValidateAgainstSchema

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use automatic freeing of the validator context to remove
'ret'/'cleanup:'.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/util/virxml.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/util/virxml.c b/src/util/virxml.c
index e9595da97d..a2fe2e6b6d 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -1671,19 +1671,15 @@ int
 virXMLValidateAgainstSchema(const char *schemafile,
                             xmlDocPtr doc)
 {
-    virXMLValidator *validator = NULL;
-    int ret = -1;
+    g_autoptr(virXMLValidator) validator = NULL;

     if (!(validator = virXMLValidatorInit(schemafile)))
         return -1;

     if (virXMLValidatorValidate(validator, doc) < 0)
-        goto cleanup;
+        return -1;

-    ret = 0;
- cleanup:
-    virXMLValidatorFree(validator);
-    return ret;
+    return 0;
 }


-- 
2.38.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux