util: bitmap: Tolerate NULL bitmaps in virBitmapEqual

After virBitmapEqual is able to compare NULL bitmaps few bits of code
can be cleaned up.

(cherry picked from commit 20448c2a72c3e420e6ad9d89f9f4302114bfef72)
Signed-off-by: Ján Tomko <jtomko@redhat.com>

Partial backport without the cleanup.
This commit is contained in:
Peter Krempa 2015-01-20 19:41:08 +01:00 committed by Ján Tomko
parent 1021df2815
commit 0e1054a129
2 changed files with 7 additions and 2 deletions

View File

@ -504,6 +504,12 @@ bool virBitmapEqual(virBitmapPtr b1, virBitmapPtr b2)
virBitmapPtr tmp;
size_t i;
if (!b1 && !b2)
return true;
if (!b1 || !b2)
return false;
if (b1->max_bit > b2->max_bit) {
tmp = b1;
b1 = b2;

View File

@ -84,8 +84,7 @@ virBitmapPtr virBitmapNewData(void *data, int len) ATTRIBUTE_NONNULL(1);
int virBitmapToData(virBitmapPtr bitmap, unsigned char **data, int *dataLen)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
bool virBitmapEqual(virBitmapPtr b1, virBitmapPtr b2)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
bool virBitmapEqual(virBitmapPtr b1, virBitmapPtr b2);
size_t virBitmapSize(virBitmapPtr bitmap)
ATTRIBUTE_NONNULL(1);