Blame SOURCES/libvirt-virStorageFileGetMetadataRecurse-Use-virHashHasEntry-instead-of-fake-pointers.patch

d76c62
From 20f764d1837f06b10c7c327b085234b6e5f876e2 Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <20f764d1837f06b10c7c327b085234b6e5f876e2@dist-git>
d76c62
From: Peter Krempa <pkrempa@redhat.com>
d76c62
Date: Fri, 28 Feb 2020 10:24:32 +0100
d76c62
Subject: [PATCH] virStorageFileGetMetadataRecurse: Use virHashHasEntry instead
d76c62
 of fake pointers
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
Replacing virHashLookup by virHashHasEntry allows us to use NULL as the
d76c62
payload of the hash table rather than putting a fake '1' pointer into
d76c62
the table.
d76c62
d76c62
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Reviewed-by: Eric Blake <eblake@redhat.com>
d76c62
(cherry picked from commit e3960f4b6d0b6d8cb8b2631f8358abf289c1cc18)
d76c62
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1798148
d76c62
Message-Id: <af53b5ff04169cfa8e40664f2b66f110560486ee.1582881363.git.pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 src/util/virstoragefile.c | 4 ++--
d76c62
 1 file changed, 2 insertions(+), 2 deletions(-)
d76c62
d76c62
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
d76c62
index 28d1d1aa1e..46d55eda96 100644
d76c62
--- a/src/util/virstoragefile.c
d76c62
+++ b/src/util/virstoragefile.c
d76c62
@@ -4992,14 +4992,14 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
d76c62
     if (!(uniqueName = virStorageFileGetUniqueIdentifier(src)))
d76c62
         goto cleanup;
d76c62
 
d76c62
-    if (virHashLookup(cycle, uniqueName)) {
d76c62
+    if (virHashHasEntry(cycle, uniqueName)) {
d76c62
         virReportError(VIR_ERR_INTERNAL_ERROR,
d76c62
                        _("backing store for %s (%s) is self-referential"),
d76c62
                        NULLSTR(src->path), uniqueName);
d76c62
         goto cleanup;
d76c62
     }
d76c62
 
d76c62
-    if (virHashAddEntry(cycle, uniqueName, (void *)1) < 0)
d76c62
+    if (virHashAddEntry(cycle, uniqueName, NULL) < 0)
d76c62
         goto cleanup;
d76c62
 
d76c62
     if ((headerLen = virStorageFileRead(src, 0, VIR_STORAGE_MAX_HEADER,
d76c62
-- 
d76c62
2.25.1
d76c62