Re: [libvirt PATCH 7/7] cpu: Replace VIR_FREE with g_free

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

 



On a Thursday in 2020, Tim Wiederhake wrote:
Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
src/cpu/cpu.c       |  2 +-
src/cpu/cpu_map.c   |  6 +++---
src/cpu/cpu_ppc64.c | 18 +++++++++---------
src/cpu/cpu_x86.c   | 10 +++++-----
4 files changed, 18 insertions(+), 18 deletions(-)


[...]

diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c
index 65d244e011..7859eef9aa 100644
--- a/src/cpu/cpu_map.c
+++ b/src/cpu/cpu_map.c
@@ -64,7 +64,7 @@ loadData(const char *mapfile,
        VIR_DEBUG("Load %s name %s", element, name);
        ctxt->node = nodes[i];
        rv = callback(ctxt, name, data);
-        VIR_FREE(name);
+        g_free(name);
        if (rv < 0)
            return -1;
    }
@@ -133,10 +133,10 @@ loadIncludes(xmlXPathContextPtr ctxt,
        }
        VIR_DEBUG("Finding CPU map include '%s'", filename);
        if (cpuMapLoadInclude(filename, vendorCB, featureCB, modelCB, data) < 0) {
-            VIR_FREE(filename);
+            g_free(filename);
            return -1;
        }
-        VIR_FREE(filename);
+        g_free(filename);
    }

    return 0;

The cases above can be converted to g_autofree

diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
index 6477b4bce7..7a36981e12 100644
--- a/src/cpu/cpu_ppc64.c
+++ b/src/cpu/cpu_ppc64.c
@@ -126,7 +126,7 @@ ppc64DataClear(virCPUppc64Data *data)
    if (!data)
        return;

-    VIR_FREE(data->pvr);
+    g_free(data->pvr);
}


g_clear_pointer. This is a *Clear function and we should not leave
stale pointers around in those.

@@ -1805,7 +1805,7 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
            if (message) \
                *message = g_strdup_printf("%s: %s", _(MSG), flagsStr); \
            VIR_DEBUG("%s: %s", MSG, flagsStr); \
-            VIR_FREE(flagsStr); \
+            g_free(flagsStr); \
        } while (0)



This one can also use g_autofree

Jano

Attachment: signature.asc
Description: PGP signature


[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