[libvirt] [PATCH] testQemuGetLatestCaps: Lower chances of hash collision

Michal Privoznik posted 1 patch 5 years ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/c9efcb38292dd3a925ccf644149f0048b1dab71f.1555592694.git.mprivozn@redhat.com
tests/testutilsqemu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt] [PATCH] testQemuGetLatestCaps: Lower chances of hash collision
Posted by Michal Privoznik 5 years ago
This function creates a list of paths to the latest capabilities
and returns them in a hash table where key is an arch string and
value is the path. Well, we know how many arches there are so
might as well use that as initial hash size.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tests/testutilsqemu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index bce847ce5e..2d6a84d017 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -879,7 +879,7 @@ testQemuGetLatestCaps(void)
     virHashTablePtr capslatest;
     size_t i;
 
-    if (!(capslatest = virHashCreate(4, virHashValueFree)))
+    if (!(capslatest = virHashCreate(ARRAY_CARDINALITY(archs), virHashValueFree)))
         goto error;
 
     VIR_TEST_VERBOSE("\n");
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list