util: Clear unused part of the map in virBitmapShrink

Some of the other functions depend on the fact that unused bits and longs are
always zero and it's less error-prone to clear it than fix the other functions.
It's enough to zero out one piece of the map since we're calling realloc() to
get rid of the rest (and updating map_len).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1540817

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander committed 2018-02-02 14:51:32 +01:00
1 parent 679543449c
commit d6e582da80
5 files changed
+36 -11

No files matched your search

+8
View File
@@ -656,6 +656,14 @@ test12(const void *opaque ATTRIBUTE_UNUSED)
TEST_MAP(1024, "34,1023");
if (virBitmapShrink(map, 35) < 0)
goto cleanup;
TEST_MAP(35, "34");
if (virBitmapShrink(map, 34) < 0)
goto cleanup;
TEST_MAP(34, "");
ret = 0;
cleanup: