[libvirt PATCH 16/39] cpu_x86: Use g_auto* in virCPUx86Compare

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

 



Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/cpu/cpu_x86.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 6758fcc170..e4e21fbed4 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1848,34 +1848,31 @@ virCPUx86Compare(virCPUDefPtr host,
                  virCPUDefPtr cpu,
                  bool failIncompatible)
 {
-    virCPUCompareResult ret = VIR_CPU_COMPARE_ERROR;
-    virCPUx86ModelPtr model = NULL;
-    char *message = NULL;
+    virCPUCompareResult ret;
+    g_autoptr(virCPUx86Model) model = NULL;
+    g_autofree char *message = NULL;
 
     if (!host || !host->model) {
         if (failIncompatible) {
             virReportError(VIR_ERR_CPU_INCOMPATIBLE, "%s",
                            _("unknown host CPU"));
-        } else {
-            VIR_WARN("unknown host CPU");
-            ret = VIR_CPU_COMPARE_INCOMPATIBLE;
+            return VIR_CPU_COMPARE_ERROR;
         }
-        goto cleanup;
+
+        VIR_WARN("unknown host CPU");
+        return VIR_CPU_COMPARE_INCOMPATIBLE;
     }
 
     ret = x86Compute(host, cpu, NULL, &message);
 
     if (ret == VIR_CPU_COMPARE_INCOMPATIBLE && failIncompatible) {
-        ret = VIR_CPU_COMPARE_ERROR;
         if (message)
             virReportError(VIR_ERR_CPU_INCOMPATIBLE, "%s", message);
         else
             virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL);
+        return VIR_CPU_COMPARE_ERROR;
     }
 
- cleanup:
-    VIR_FREE(message);
-    x86ModelFree(model);
     return ret;
 }
 
-- 
2.26.0





[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