Re: [PATCH 5/5] util: bitmap: Tolerate NULL bitmaps in virBitmapEqual

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 22.01.2015 11:53, Peter Krempa wrote:
> ---
>  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 05c50e4..d5b0035 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 565264c..a347f0a 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);
> 

There are some places in the code that already call this and do the
checks you're introducing. Can we drop the duplicity then?

Michal

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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]