[libvirt PATCH 13/14] security: apparmor: use automatic cleanup in load_profile

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

 



Use g_auto for virCommand and char * and drop the cleanup label.

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/security/security_apparmor.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
index dadcfd67db..d1087aa10c 100644
--- a/src/security/security_apparmor.c
+++ b/src/security/security_apparmor.c
@@ -163,14 +163,13 @@ load_profile(virSecurityManager *mgr G_GNUC_UNUSED,
              const char *fn,
              bool append)
 {
-    int rc = -1;
     bool create = true;
-    char *xml = NULL;
-    virCommand *cmd = NULL;
+    g_autofree char *xml = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     xml = virDomainDefFormat(def, NULL, VIR_DOMAIN_DEF_FORMAT_SECURE);
     if (!xml)
-        goto cleanup;
+        return -1;
 
     if (profile_status_file(profile) >= 0)
         create = false;
@@ -191,13 +190,7 @@ load_profile(virSecurityManager *mgr G_GNUC_UNUSED,
                            virLogGetDefaultPriority());
 
     virCommandSetInputBuffer(cmd, xml);
-    rc = virCommandRun(cmd, NULL);
-
- cleanup:
-    VIR_FREE(xml);
-    virCommandFree(cmd);
-
-    return rc;
+    return virCommandRun(cmd, NULL);
 }
 
 static int
-- 
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