[PATCH 10/16] qemuDomainAddChardevTLSObjects: Refactor cleanup

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

 



Switch to automatic memory clearing for the two virJSONValues and remove
the 'cleanup' label and 'ret' variable.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_hotplug.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 0e798dc237..c4f11edf6b 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1863,25 +1863,22 @@ qemuDomainAddChardevTLSObjects(virQEMUDriver *driver,
                                char **tlsAlias,
                                const char **secAlias)
 {
-    int ret = -1;
     g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
     qemuDomainObjPrivate *priv = vm->privateData;
     qemuDomainChrSourcePrivate *chrSourcePriv;
     qemuDomainSecretInfo *secinfo = NULL;
-    virJSONValue *tlsProps = NULL;
-    virJSONValue *secProps = NULL;
+    g_autoptr(virJSONValue) tlsProps = NULL;
+    g_autoptr(virJSONValue) secProps = NULL;

     /* NB: This may alter haveTLS based on cfg */
     qemuDomainPrepareChardevSourceTLS(dev, cfg);

     if (dev->type != VIR_DOMAIN_CHR_TYPE_TCP ||
-        dev->data.tcp.haveTLS != VIR_TRISTATE_BOOL_YES) {
-        ret = 0;
-        goto cleanup;
-    }
+        dev->data.tcp.haveTLS != VIR_TRISTATE_BOOL_YES)
+        return 0;

     if (qemuDomainSecretChardevPrepare(cfg, priv, devAlias, dev) < 0)
-        goto cleanup;
+        return -1;

     if ((chrSourcePriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev)))
         secinfo = chrSourcePriv->secinfo;
@@ -1890,27 +1887,22 @@ qemuDomainAddChardevTLSObjects(virQEMUDriver *driver,
         *secAlias = secinfo->alias;

     if (!(*tlsAlias = qemuAliasTLSObjFromSrcAlias(charAlias)))
-        goto cleanup;
+        return -1;

     if (qemuDomainGetTLSObjects(secinfo,
                                 cfg->chardevTLSx509certdir,
                                 dev->data.tcp.listen,
                                 cfg->chardevTLSx509verify,
                                 *tlsAlias, &tlsProps, &secProps) < 0)
-        goto cleanup;
+        return -1;
+
     dev->data.tcp.tlscreds = true;

     if (qemuDomainAddTLSObjects(driver, vm, QEMU_ASYNC_JOB_NONE,
                                 &secProps, &tlsProps) < 0)
-        goto cleanup;
-
-    ret = 0;
-
- cleanup:
-    virJSONValueFree(tlsProps);
-    virJSONValueFree(secProps);
+        return -1;

-    return ret;
+    return 0;
 }


-- 
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