From 0e1054a129bcc2cad43818ee730bbc723997b757 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 20 Jan 2015 19:41:08 +0100 Subject: [PATCH] util: bitmap: Tolerate NULL bitmaps in virBitmapEqual MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Partial backport without the cleanup. --- src/util/virbitmap.c | 6 ++++++ src/util/virbitmap.h | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 05c50e4e8e..d5b0035f50 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -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; diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h index 565264cc4c..a347f0afdc 100644 --- a/src/util/virbitmap.h +++ b/src/util/virbitmap.h @@ -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); -- GitLab