From: Peter Krempa Date: Fri, 22 Jan 2021 16:03:22 +0000 (+0100) Subject: virStorageSourceGetMetadata: Refactor cleanup X-Git-Tag: v7.1.0-rc1~423 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e87a99ff76120a29e7f5f40acb9dc77bf7f5c01;p=thirdparty%2Flibvirt.git virStorageSourceGetMetadata: Refactor cleanup Use g_autoptr for the hash table and remove the 'ret' variable. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_source.c index 9d3761f5bd..51f97b13ef 100644 --- a/src/storage_file/storage_source.c +++ b/src/storage_file/storage_source.c @@ -1421,17 +1421,13 @@ virStorageSourceGetMetadata(virStorageSourcePtr src, uid_t uid, gid_t gid, bool report_broken) { - GHashTable *cycle = NULL; + g_autoptr(GHashTable) cycle = virHashNew(NULL); virStorageType actualType = virStorageSourceGetActualType(src); - int ret = -1; VIR_DEBUG("path=%s format=%d uid=%u gid=%u report_broken=%d", src->path, src->format, (unsigned int)uid, (unsigned int)gid, report_broken); - if (!(cycle = virHashNew(NULL))) - return -1; - if (src->format <= VIR_STORAGE_FILE_NONE) { if (actualType == VIR_STORAGE_TYPE_DIR) src->format = VIR_STORAGE_FILE_DIR; @@ -1439,9 +1435,6 @@ virStorageSourceGetMetadata(virStorageSourcePtr src, src->format = VIR_STORAGE_FILE_RAW; } - ret = virStorageSourceGetMetadataRecurse(src, src, uid, gid, - report_broken, cycle, 1); - - virHashFree(cycle); - return ret; + return virStorageSourceGetMetadataRecurse(src, src, uid, gid, + report_broken, cycle, 1); }