mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 03:21:19 +00:00
conf: convert final DIR* to g_autoptr
This use of DIR* was re-using the same function-scope DIR* each time through a for loop, and due to multiple error gotos in the loop, it needed to have the scope of the DIR* reduced to just the loop at the same time as switching to g_autoptr. That's what this patch does. Signed-off-by: Laine Stump <laine@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
c0ae4919e3
commit
e98f216719
@ -1837,7 +1837,6 @@ virCapabilitiesInitCaches(virCapsPtr caps)
|
|||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
virBitmapPtr cpus = NULL;
|
virBitmapPtr cpus = NULL;
|
||||||
ssize_t pos = -1;
|
ssize_t pos = -1;
|
||||||
DIR *dirp = NULL;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
char *type = NULL;
|
char *type = NULL;
|
||||||
@ -1860,13 +1859,11 @@ virCapabilitiesInitCaches(virCapsPtr caps)
|
|||||||
|
|
||||||
while ((pos = virBitmapNextSetBit(cpus, pos)) >= 0) {
|
while ((pos = virBitmapNextSetBit(cpus, pos)) >= 0) {
|
||||||
int rv = -1;
|
int rv = -1;
|
||||||
|
g_autoptr(DIR) dirp = NULL;
|
||||||
|
|
||||||
VIR_FREE(path);
|
VIR_FREE(path);
|
||||||
path = g_strdup_printf("%s/cpu/cpu%zd/cache/", SYSFS_SYSTEM_PATH, pos);
|
path = g_strdup_printf("%s/cpu/cpu%zd/cache/", SYSFS_SYSTEM_PATH, pos);
|
||||||
|
|
||||||
VIR_DIR_CLOSE(dirp);
|
|
||||||
dirp = NULL;
|
|
||||||
|
|
||||||
rv = virDirOpenIfExists(&dirp, path);
|
rv = virDirOpenIfExists(&dirp, path);
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1971,7 +1968,6 @@ virCapabilitiesInitCaches(virCapsPtr caps)
|
|||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(type);
|
VIR_FREE(type);
|
||||||
VIR_FREE(path);
|
VIR_FREE(path);
|
||||||
VIR_DIR_CLOSE(dirp);
|
|
||||||
virCapsHostCacheBankFree(bank);
|
virCapsHostCacheBankFree(bank);
|
||||||
virBitmapFree(cpus);
|
virBitmapFree(cpus);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user