libvirt-lxc: use g_autoptr for virCgroup

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
Pavel Hrdina 2020-09-22 12:49:33 +02:00
parent ca335643d6
commit ab8cc94ccc

View File

@ -289,7 +289,7 @@ int virDomainLxcEnterCGroup(virDomainPtr domain,
unsigned int flags) unsigned int flags)
{ {
virConnectPtr conn; virConnectPtr conn;
virCgroupPtr cgroup = NULL; g_autoptr(virCgroup) cgroup = NULL;
VIR_DOMAIN_DEBUG(domain, "flags=0x%x", flags); VIR_DOMAIN_DEBUG(domain, "flags=0x%x", flags);
@ -307,12 +307,9 @@ int virDomainLxcEnterCGroup(virDomainPtr domain,
if (virCgroupAddProcess(cgroup, getpid()) < 0) if (virCgroupAddProcess(cgroup, getpid()) < 0)
goto error; goto error;
virCgroupFree(cgroup);
return 0; return 0;
error: error:
virDispatchError(NULL); virDispatchError(NULL);
virCgroupFree(cgroup);
return -1; return -1;
} }