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

Michal Privoznik mprivozn at redhat.com
Thu Apr 18 13:04:54 UTC 2019


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 at 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




More information about the libvir-list mailing list