[PATCH 2/5] cpu_arm.c: modernize virCPUarmUpdate

Daniel Henrique Barboza danielhb413 at gmail.com
Fri May 22 19:56:17 UTC 2020


Use automatic cleanup of variables.

Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
---
 src/cpu/cpu_arm.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c
index 6f6c6a1479..cd4f720c95 100644
--- a/src/cpu/cpu_arm.c
+++ b/src/cpu/cpu_arm.c
@@ -415,8 +415,7 @@ static int
 virCPUarmUpdate(virCPUDefPtr guest,
                 const virCPUDef *host)
 {
-    int ret = -1;
-    virCPUDefPtr updated = NULL;
+    g_autoptr(virCPUDef) updated = NULL;
 
     if (guest->mode != VIR_CPU_MODE_HOST_MODEL)
         return 0;
@@ -424,24 +423,21 @@ virCPUarmUpdate(virCPUDefPtr guest,
     if (!host) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("unknown host CPU model"));
-        goto cleanup;
+        return -1;
     }
 
     if (!(updated = virCPUDefCopyWithoutModel(guest)))
-        goto cleanup;
+        return -1;
 
     updated->mode = VIR_CPU_MODE_CUSTOM;
     if (virCPUDefCopyModel(updated, host, true) < 0)
-        goto cleanup;
+        return -1;
 
     virCPUDefStealModel(guest, updated, false);
     guest->mode = VIR_CPU_MODE_CUSTOM;
     guest->match = VIR_CPU_MATCH_EXACT;
-    ret = 0;
 
- cleanup:
-    virCPUDefFree(updated);
-    return ret;
+    return 0;
 }
 
 
-- 
2.26.2




More information about the libvir-list mailing list