[libvirt PATCH 5/7] cpu: Replace VIR_ALLOC with g_new0

Ján Tomko jtomko at redhat.com
Thu Sep 10 12:19:35 UTC 2020


On a Thursday in 2020, Tim Wiederhake wrote:
>Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
>---
> src/cpu/cpu.c       |  4 +---
> src/cpu/cpu_ppc64.c | 25 ++++++++-----------------
> 2 files changed, 9 insertions(+), 20 deletions(-)
>
>diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
>index 69e4205e4b..c3eef52c79 100644
>--- a/src/cpu/cpu.c
>+++ b/src/cpu/cpu.c
>@@ -399,17 +392,15 @@ static virCPUDataPtr
> ppc64MakeCPUData(virArch arch,
>                  virCPUppc64Data *data)
> {
>-    virCPUDataPtr cpuData;
>-
>-    if (VIR_ALLOC(cpuData) < 0)
>-        return NULL;
>+    g_autoptr(virCPUData) cpuData = NULL;
>
>+    cpuData = g_new0(virCPUData, 1);
>     cpuData->arch = arch;
>
>     if (ppc64DataCopy(&cpuData->data.ppc64, data) < 0)
>-        VIR_FREE(cpuData);
>+        return NULL;
>
>-    return cpuData;
>+    return g_steal_pointer(&cpuData);

This combines the VIR_ALLOC -> g_new0 replacement with
other refactors.

For neat separation of changes into commits, it would be
nicer to have the other changes separate. But I could live
with the changes being here, if you mention them in the commit message.

Jano


> }
>
> static virCPUCompareResult
>-- 
>2.26.2
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20200910/1d4bf610/attachment-0001.sig>


More information about the libvir-list mailing list