[libvirt PATCH 4/6] qemu: refactor virQEMUCapsNewCopy

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

 



Use g_auto and remove pointless labels.

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/qemu/qemu_capabilities.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 380d0a5694..fecd332604 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1953,7 +1953,7 @@ virQEMUCapsAccelCopy(virQEMUCapsAccel *dst,
 
 virQEMUCaps *virQEMUCapsNewCopy(virQEMUCaps *qemuCaps)
 {
-    virQEMUCaps *ret = virQEMUCapsNewBinary(qemuCaps->binary);
+    g_autoptr(virQEMUCaps) ret = virQEMUCapsNewBinary(qemuCaps->binary);
     size_t i;
 
     if (!ret)
@@ -1980,7 +1980,7 @@ virQEMUCaps *virQEMUCapsNewCopy(virQEMUCaps *qemuCaps)
 
     if (virQEMUCapsAccelCopy(&ret->kvm, &qemuCaps->kvm) < 0 ||
         virQEMUCapsAccelCopy(&ret->tcg, &qemuCaps->tcg) < 0)
-        goto error;
+        return NULL;
 
     ret->gicCapabilities = g_new0(virGICCapability, qemuCaps->ngicCapabilities);
     ret->ngicCapabilities = qemuCaps->ngicCapabilities;
@@ -1990,13 +1990,9 @@ virQEMUCaps *virQEMUCapsNewCopy(virQEMUCaps *qemuCaps)
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST) &&
         virQEMUCapsSEVInfoCopy(&ret->sevCapabilities,
                                qemuCaps->sevCapabilities) < 0)
-        goto error;
+        return NULL;
 
-    return ret;
-
- error:
-    virObjectUnref(ret);
-    return NULL;
+    return g_steal_pointer(&ret);
 }
 
 
-- 
2.31.1




[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