mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
util: reduce scope of a DIR * in virCgroupV1SetOwner()
DIR *dh is being re-used each time through the for loop of this function, so it must be closed and then re-opened, which means we can't convert it to g_autoptr. By moving the definition of dh inside the for loop, we make it possible to trivially convert to g_autoptr (which will happen in a subsequent patch) NB: VIR_DIR_CLOSE() is already called at the bottom of the for loop, so removing the VIR_DIR_CLOSE() at the end of the function is *not* creating a leak of a DIR*! Signed-off-by: Laine Stump <laine@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
21f659d952
commit
098f03c29e
@ -875,12 +875,12 @@ virCgroupV1SetOwner(virCgroupPtr cgroup,
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
DIR *dh = NULL;
|
|
||||||
int direrr;
|
int direrr;
|
||||||
|
|
||||||
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
||||||
g_autofree char *base = NULL;
|
g_autofree char *base = NULL;
|
||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
|
DIR *dh = NULL;
|
||||||
|
|
||||||
if (!((1 << i) & controllers))
|
if (!((1 << i) & controllers))
|
||||||
continue;
|
continue;
|
||||||
@ -922,7 +922,6 @@ virCgroupV1SetOwner(virCgroupPtr cgroup,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_DIR_CLOSE(dh);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user