mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 18:05:20 +00:00
virStoragePoolObjLoadAllConfigs: Use automatic memory clearing
Refactor the inner loop to automatically free temporary variables and remove unreachable error paths. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
7cf5b88338
commit
8a80df95ac
@ -1736,27 +1736,15 @@ virStoragePoolObjLoadAllConfigs(virStoragePoolObjList *pools,
|
|||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
while ((ret = virDirRead(dir, &entry, configDir)) > 0) {
|
while ((ret = virDirRead(dir, &entry, configDir)) > 0) {
|
||||||
char *path;
|
g_autofree char *path = virFileBuildPath(configDir, entry->d_name, NULL);
|
||||||
char *autostartLink;
|
g_autofree char *autostartLink = virFileBuildPath(autostartDir, entry->d_name, NULL);
|
||||||
virStoragePoolObj *obj;
|
virStoragePoolObj *obj;
|
||||||
|
|
||||||
if (!virStringHasSuffix(entry->d_name, ".xml"))
|
if (!virStringHasSuffix(entry->d_name, ".xml"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!(path = virFileBuildPath(configDir, entry->d_name, NULL)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!(autostartLink = virFileBuildPath(autostartDir, entry->d_name,
|
|
||||||
NULL))) {
|
|
||||||
VIR_FREE(path);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
obj = virStoragePoolObjLoad(pools, entry->d_name, path, autostartLink);
|
obj = virStoragePoolObjLoad(pools, entry->d_name, path, autostartLink);
|
||||||
virStoragePoolObjEndAPI(&obj);
|
virStoragePoolObjEndAPI(&obj);
|
||||||
|
|
||||||
VIR_FREE(path);
|
|
||||||
VIR_FREE(autostartLink);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user