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

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

 



Use automatic cleanup of variables.

Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
---
 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




[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