[libvirt PATCH 07/10] virStorageAdapterParseXML: Use g_autofree

Tim Wiederhake twiederh at redhat.com
Wed May 19 14:10:09 UTC 2021


Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 src/conf/storage_adapter_conf.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/conf/storage_adapter_conf.c b/src/conf/storage_adapter_conf.c
index 6b5a58e1e7..717d00dc4a 100644
--- a/src/conf/storage_adapter_conf.c
+++ b/src/conf/storage_adapter_conf.c
@@ -168,9 +168,8 @@ virStorageAdapterParseXML(virStorageAdapter *adapter,
                           xmlNodePtr node,
                           xmlXPathContextPtr ctxt)
 {
-    int ret = -1;
     VIR_XPATH_NODE_AUTORESTORE(ctxt)
-    char *adapter_type = NULL;
+    g_autofree char *adapter_type = NULL;
 
     ctxt->node = node;
 
@@ -180,27 +179,23 @@ virStorageAdapterParseXML(virStorageAdapter *adapter,
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("Unknown pool adapter type '%s'"),
                            adapter_type);
-            goto cleanup;
+            return -1;
         }
 
         if ((adapter->type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST) &&
             (virStorageAdapterParseXMLFCHost(node, &adapter->data.fchost)) < 0)
-                goto cleanup;
+            return -1;
 
         if ((adapter->type == VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST) &&
             (virStorageAdapterParseXMLSCSIHost(node, ctxt,
                                                &adapter->data.scsi_host)) < 0)
-                goto cleanup;
+            return -1;
     } else {
         if (virStorageAdapterParseXMLLegacy(node, ctxt, adapter) < 0)
-            goto cleanup;
+            return -1;
     }
 
-    ret = 0;
-
- cleanup:
-    VIR_FREE(adapter_type);
-    return ret;
+    return 0;
 }
 
 
-- 
2.26.3




More information about the libvir-list mailing list