[PATCH 5/9] virStorageFileGetMetadataRecurse: Use virHashHasEntry instead of fake pointers

Peter Krempa pkrempa at redhat.com
Mon Feb 17 17:13:55 UTC 2020


Replacing virHashLookup by virHashHasEntry allows to use NULL as the
payload of the hash table rather than putting a fake '1' pointer into
the table.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/util/virstoragefile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index cf37744d6f..bb3fa65a14 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -4992,14 +4992,14 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
     if (!(uniqueName = virStorageFileGetUniqueIdentifier(src)))
         goto cleanup;

-    if (virHashLookup(cycle, uniqueName)) {
+    if (virHashHasEntry(cycle, uniqueName)) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("backing store for %s (%s) is self-referential"),
                        NULLSTR(src->path), uniqueName);
         goto cleanup;
     }

-    if (virHashAddEntry(cycle, uniqueName, (void *)1) < 0)
+    if (virHashAddEntry(cycle, uniqueName, NULL) < 0)
         goto cleanup;

     if ((headerLen = virStorageFileRead(src, 0, VIR_STORAGE_MAX_HEADER,
-- 
2.24.1




More information about the libvir-list mailing list