From: Peter Krempa <pkrempa@redhat.com> Use automatic freeing for 'ret' and stop checking return value from 'virStorageSourceMetadataNew' which can't fail. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/storage_file/storage_source.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_source.c index fb4fc48947..651822eb65 100644 --- a/src/storage_file/storage_source.c +++ b/src/storage_file/storage_source.c @@ -119,17 +119,12 @@ virStorageSourceGetMetadataFromBuf(const char *path, size_t len, int format) { - virStorageSource *ret = NULL; + g_autoptr(virStorageSource) ret = virStorageSourceMetadataNew(path, format); - if (!(ret = virStorageSourceMetadataNew(path, format))) + if (virStorageFileProbeGetMetadata(ret, buf, len) < 0) return NULL; - if (virStorageFileProbeGetMetadata(ret, buf, len) < 0) { - virObjectUnref(ret); - return NULL; - } - - return ret; + return g_steal_pointer(&ret); } -- 2.54.0