]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu_x86: Use g_auto* in virCPUx86Compare
authorJiri Denemark <jdenemar@redhat.com>
Wed, 25 Mar 2020 10:30:24 +0000 (11:30 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 8 Apr 2020 15:41:01 +0000 (17:41 +0200)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/cpu/cpu_x86.c

index 7a59680516faaf04d880fb938e0ab56ac269b829..feefd6cfee6822bb59c4bdb644e61cc43d9e7604 100644 (file)
@@ -1847,32 +1847,30 @@ virCPUx86Compare(virCPUDefPtr host,
                  virCPUDefPtr cpu,
                  bool failIncompatible)
 {
-    virCPUCompareResult ret = VIR_CPU_COMPARE_ERROR;
-    char *message = NULL;
+    virCPUCompareResult ret;
+    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);
     return ret;
 }