mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virStorageSourceGetMetadata: Refactor cleanup
Use g_autoptr for the hash table and remove the 'ret' variable. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
2d29a3a9d8
commit
2e87a99ff7
@ -1421,17 +1421,13 @@ virStorageSourceGetMetadata(virStorageSourcePtr src,
|
|||||||
uid_t uid, gid_t gid,
|
uid_t uid, gid_t gid,
|
||||||
bool report_broken)
|
bool report_broken)
|
||||||
{
|
{
|
||||||
GHashTable *cycle = NULL;
|
g_autoptr(GHashTable) cycle = virHashNew(NULL);
|
||||||
virStorageType actualType = virStorageSourceGetActualType(src);
|
virStorageType actualType = virStorageSourceGetActualType(src);
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
VIR_DEBUG("path=%s format=%d uid=%u gid=%u report_broken=%d",
|
VIR_DEBUG("path=%s format=%d uid=%u gid=%u report_broken=%d",
|
||||||
src->path, src->format, (unsigned int)uid, (unsigned int)gid,
|
src->path, src->format, (unsigned int)uid, (unsigned int)gid,
|
||||||
report_broken);
|
report_broken);
|
||||||
|
|
||||||
if (!(cycle = virHashNew(NULL)))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (src->format <= VIR_STORAGE_FILE_NONE) {
|
if (src->format <= VIR_STORAGE_FILE_NONE) {
|
||||||
if (actualType == VIR_STORAGE_TYPE_DIR)
|
if (actualType == VIR_STORAGE_TYPE_DIR)
|
||||||
src->format = VIR_STORAGE_FILE_DIR;
|
src->format = VIR_STORAGE_FILE_DIR;
|
||||||
@ -1439,9 +1435,6 @@ virStorageSourceGetMetadata(virStorageSourcePtr src,
|
|||||||
src->format = VIR_STORAGE_FILE_RAW;
|
src->format = VIR_STORAGE_FILE_RAW;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virStorageSourceGetMetadataRecurse(src, src, uid, gid,
|
return virStorageSourceGetMetadataRecurse(src, src, uid, gid,
|
||||||
report_broken, cycle, 1);
|
report_broken, cycle, 1);
|
||||||
|
|
||||||
virHashFree(cycle);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user