Doh - I was looking at these while I see Michal posted an ACK series...
so hopefully before you push...


$SUBJ

Introduce

On 03/22/2016 10:00 AM, Peter Krempa wrote:
> In some cases it's impractical to use the regular APIs as the bitmap
> size needs to be pre-declared. These new APIs allow to use bitmaps that
> self expand.
> 
> The new code adds a property to the bitmap to track the alocation of

allocation

> memory so that VIR_RESIZE_N can be used.
> ---
>  src/libvirt_private.syms |  3 ++
>  src/util/virbitmap.c     | 93 
> ++++++++++++++++++++++++++++++++++++++++++++++++
>  src/util/virbitmap.h     |  8 +++++
>  tests/virbitmaptest.c    | 51 ++++++++++++++++++++++++++
>  4 files changed, 155 insertions(+)
> 

[...]

> diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
> index 967a5c8..92f1e6e 100644
> --- a/tests/virbitmaptest.c
> +++ b/tests/virbitmaptest.c
> @@ -590,6 +590,54 @@ test11(const void *opaque)
>      return ret;
>  }
> 
> +#define TEST_MAP(sz, expect)                                                 
>   \
> +    do {                                                                     
>   \
> +        char *actual = virBitmapFormat(map);                                 
>   \
> +        if (virBitmapSize(map) != sz) {                                      
>   \
> +            fprintf(stderr, "\n expected bitmap size: '%d' actual size: "    
>   \
> +                    "'%zu'\n", sz, virBitmapSize(map));                      
>   \

According to Coverity, actual can be leaked here...

> +            goto cleanup;                                                    
>   \
> +        }                                                                    
>   \
> +        if (STRNEQ_NULLABLE(expect, actual)) {                               
>   \
> +            fprintf(stderr, "\n expected bitmap contents '%s' actual 
> contents "\
> +                    "'%s'\n", NULLSTR(expect), NULLSTR(actual));             
>   \
> +            VIR_FREE(actual);                                                
>   \
> +            goto cleanup;                                                    
>   \
> +        }                                                                    
>   \
> +        VIR_FREE(actual);                                                    
>   \
> +    } while (0)
> +
> +/* test self-expanding bitmap APIs */
> +static int
> +test12(const void *opaque ATTRIBUTE_UNUSED)
> +{
> +    virBitmapPtr map = NULL;
> +    int ret = -1;
> +
> +    if (!(map = virBitmapNewEmpty()))
> +        return -1;
> +
> +    TEST_MAP(0, "");
> +
> +    if (virBitmapSetBitExpand(map, 100) < 0)
> +        goto cleanup;
> +
> +    TEST_MAP(101, "100");
> +
> +    if (virBitmapClearBitExpand(map, 150) < 0)
> +        goto cleanup;
> +
> +    TEST_MAP(151, "100");
> +
> +    ret = 0;
> +
> + cleanup:
> +    virBitmapFree(map);
> +    return ret;
> +}
> +#undef TEST_MAP
> +
> +

John

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

Reply via email to