mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
util: manually set dirp to NULL after closing in virCapabilitiesInitCache()
In all uses of VIR_DIR_CLOSE() except one, the DIR* is never referenced after closing all the way until it goes out of scope. virCapabilitiesInitCaches(), however, reuses the same DIR* over and over in a loop, but due to having many error conditions that result in a goto out of the loop, it's not well suited to reducing the scope of the variable until we introduce a g_autoptr cleanup function for DIR*. In preparation for doing just that, we need to get rid of the side effect of VIR_DIR_CLOSE() setting the DIR* to NULL, so in this one case, let's manually set the DIR* to NULL. Then in an upcoming patch we can safely remove the side effect from VIR_DIR_CLOSE(). This extra/ugly bit of code is only temporary: once we introduce the g_autoptr cleanup function for DIR*, we will remove this manual close/clear completely anyway. Signed-off-by: Laine Stump <laine@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
098f03c29e
commit
7f42bdf5c0
@ -1865,6 +1865,7 @@ virCapabilitiesInitCaches(virCapsPtr caps)
|
|||||||
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);
|
VIR_DIR_CLOSE(dirp);
|
||||||
|
dirp = NULL;
|
||||||
|
|
||||||
rv = virDirOpenIfExists(&dirp, path);
|
rv = virDirOpenIfExists(&dirp, path);
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user