From: Ján Tomko Date: Mon, 13 Dec 2021 13:06:17 +0000 (+0100) Subject: security: apparmor: use automatic cleanup in load_profile X-Git-Tag: v8.0.0-rc1~230 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eff68d3637d4530b8813062a730ec13ac24a67a9;p=thirdparty%2Flibvirt.git security: apparmor: use automatic cleanup in load_profile Use g_auto for virCommand and char * and drop the cleanup label. Signed-off-by: Ján Tomko Reviewed-by: Michal Privoznik --- 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