render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
a41c76
From 2631931d1dc94aeab384d92bd00866de912c9b7d Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <2631931d1dc94aeab384d92bd00866de912c9b7d@dist-git>
a41c76
From: Jiri Denemark <jdenemar@redhat.com>
a41c76
Date: Tue, 26 May 2020 10:59:22 +0200
a41c76
Subject: [PATCH] cpu_x86: Use g_auto* in virCPUx86Update
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit e0244a786db265647ab6c1c37ca3852876e4b0a3)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Message-Id: <1d8ad3e099081c35a41e1013458fa52d8fb4fae0.1590483392.git.jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/cpu/cpu_x86.c | 15 +++++----------
a41c76
 1 file changed, 5 insertions(+), 10 deletions(-)
a41c76
a41c76
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
a41c76
index 98f7863b6f..1f7a8802f6 100644
a41c76
--- a/src/cpu/cpu_x86.c
a41c76
+++ b/src/cpu/cpu_x86.c
a41c76
@@ -2853,9 +2853,8 @@ static int
a41c76
 virCPUx86Update(virCPUDefPtr guest,
a41c76
                 const virCPUDef *host)
a41c76
 {
a41c76
-    virCPUx86ModelPtr model = NULL;
a41c76
+    g_autoptr(virCPUx86Model) model = NULL;
a41c76
     virCPUx86MapPtr map;
a41c76
-    int ret = -1;
a41c76
     size_t i;
a41c76
 
a41c76
     if (!host) {
a41c76
@@ -2868,14 +2867,14 @@ virCPUx86Update(virCPUDefPtr guest,
a41c76
         return -1;
a41c76
 
a41c76
     if (!(model = x86ModelFromCPU(host, map, -1)))
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
 
a41c76
     for (i = 0; i < guest->nfeatures; i++) {
a41c76
         if (guest->features[i].policy == VIR_CPU_FEATURE_OPTIONAL) {
a41c76
             int supported = x86FeatureInData(guest->features[i].name,
a41c76
                                              &model->data, map);
a41c76
             if (supported < 0)
a41c76
-                goto cleanup;
a41c76
+                return -1;
a41c76
             else if (supported)
a41c76
                 guest->features[i].policy = VIR_CPU_FEATURE_REQUIRE;
a41c76
             else
a41c76
@@ -2885,13 +2884,9 @@ virCPUx86Update(virCPUDefPtr guest,
a41c76
 
a41c76
     if (guest->mode == VIR_CPU_MODE_HOST_MODEL ||
a41c76
         guest->match == VIR_CPU_MATCH_MINIMUM)
a41c76
-        ret = x86UpdateHostModel(guest, host);
a41c76
-    else
a41c76
-        ret = 0;
a41c76
+        return x86UpdateHostModel(guest, host);
a41c76
 
a41c76
- cleanup:
a41c76
-    x86ModelFree(model);
a41c76
-    return ret;
a41c76
+    return 0;
a41c76
 }
a41c76
 
a41c76
 
a41c76
-- 
a41c76
2.26.2
a41c76