mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-30 21:47:18 +00:00
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 <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
fd206c2867
commit
eff68d3637
@ -163,14 +163,13 @@ load_profile(virSecurityManager *mgr G_GNUC_UNUSED,
|
|||||||
const char *fn,
|
const char *fn,
|
||||||
bool append)
|
bool append)
|
||||||
{
|
{
|
||||||
int rc = -1;
|
|
||||||
bool create = true;
|
bool create = true;
|
||||||
char *xml = NULL;
|
g_autofree char *xml = NULL;
|
||||||
virCommand *cmd = NULL;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
|
|
||||||
xml = virDomainDefFormat(def, NULL, VIR_DOMAIN_DEF_FORMAT_SECURE);
|
xml = virDomainDefFormat(def, NULL, VIR_DOMAIN_DEF_FORMAT_SECURE);
|
||||||
if (!xml)
|
if (!xml)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (profile_status_file(profile) >= 0)
|
if (profile_status_file(profile) >= 0)
|
||||||
create = false;
|
create = false;
|
||||||
@ -191,13 +190,7 @@ load_profile(virSecurityManager *mgr G_GNUC_UNUSED,
|
|||||||
virLogGetDefaultPriority());
|
virLogGetDefaultPriority());
|
||||||
|
|
||||||
virCommandSetInputBuffer(cmd, xml);
|
virCommandSetInputBuffer(cmd, xml);
|
||||||
rc = virCommandRun(cmd, NULL);
|
return virCommandRun(cmd, NULL);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(xml);
|
|
||||||
virCommandFree(cmd);
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user