[libvirt PATCH v3 2/8] cpu_map: Use g_auto* in loadData

Tim Wiederhake twiederh at redhat.com
Fri Sep 11 13:22:43 UTC 2020


Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
Reviewed-by: Ján Tomko <jtomko at redhat.com>
---
 src/cpu/cpu_map.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c
index 65d244e011..53c8cbba6b 100644
--- a/src/cpu/cpu_map.c
+++ b/src/cpu/cpu_map.c
@@ -55,8 +55,9 @@ loadData(const char *mapfile,
     }
 
     for (i = 0; i < n; i++) {
-        char *name = virXMLPropString(nodes[i], "name");
-        if (!name) {
+        g_autofree char *name = NULL;
+
+        if (!(name = virXMLPropString(nodes[i], "name"))) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("cannot find %s name in CPU map '%s'"), element, mapfile);
             return -1;
@@ -64,7 +65,6 @@ loadData(const char *mapfile,
         VIR_DEBUG("Load %s name %s", element, name);
         ctxt->node = nodes[i];
         rv = callback(ctxt, name, data);
-        VIR_FREE(name);
         if (rv < 0)
             return -1;
     }
-- 
2.26.2




More information about the libvir-list mailing list