[PATCH 4/4] virQEMUDriverConfigLoadSWTPMEntry: use VIR_AUTOFREE

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

 



Switch the function to use VIR_AUTOFREE and VIR_AUTOPTR macros
to get rid of the cleanup section.

Requested-by: John Ferlan <jferlan@xxxxxxxxxx>
Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/qemu/qemu_conf.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 524e5d4d0f..ba491e448b 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -984,24 +984,20 @@ static int
 virQEMUDriverConfigLoadSWTPMEntry(virQEMUDriverConfigPtr cfg,
                                   virConfPtr conf)
 {
-    char *swtpm_user = NULL, *swtpm_group = NULL;
-    int ret = -1;
+    VIR_AUTOFREE(char *) swtpm_user = NULL;
+    VIR_AUTOFREE(char *) swtpm_group = NULL;
 
     if (virConfGetValueString(conf, "swtpm_user", &swtpm_user) < 0)
-        goto cleanup;
+        return -1;
     if (swtpm_user && virGetUserID(swtpm_user, &cfg->swtpm_user) < 0)
-        goto cleanup;
+        return -1;
 
     if (virConfGetValueString(conf, "swtpm_group", &swtpm_group) < 0)
-        goto cleanup;
+        return -1;
     if (swtpm_group && virGetGroupID(swtpm_group, &cfg->swtpm_group) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    VIR_FREE(swtpm_user);
-    VIR_FREE(swtpm_group);
-    return ret;
+    return 0;
 }
 
 
-- 
2.16.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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