Since virBitmapSubtract is unused modify it to perform bitmap intersection. --- src/libvirt_private.syms | 2 +- src/util/virbitmap.c | 14 +++++++------- src/util/virbitmap.h | 2 +- tests/virbitmaptest.c | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3f94521df..4ad1f7a60 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1295,6 +1295,7 @@ virBitmapEqual; virBitmapFormat; virBitmapFree; virBitmapGetBit; +virBitmapIntersect; virBitmapIsAllClear; virBitmapIsAllSet; virBitmapIsBitSet; @@ -1315,7 +1316,6 @@ virBitmapSetBit; virBitmapSetBitExpand; virBitmapSize; virBitmapString; -virBitmapSubtract; virBitmapToData; virBitmapToDataBuf; diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index eac63d997..a5077fe7c 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -1091,15 +1091,15 @@ virBitmapOverlaps(virBitmapPtr b1, } /** - * virBitmapSubtract: - * @a: minuend/result - * @b: subtrahend + * virBitmapIntersect: + * @a: bitmap, modified to contain result + * @b: bitmap * - * Performs bitwise subtraction: a = a - b + * Performs intersection of two bitmaps: a = intersect(a, b) */ void -virBitmapSubtract(virBitmapPtr a, - virBitmapPtr b) +virBitmapIntersect(virBitmapPtr a, + virBitmapPtr b) { size_t i; size_t max = a->map_len; @@ -1108,5 +1108,5 @@ virBitmapSubtract(virBitmapPtr a, max = b->map_len; for (i = 0; i < max; i++) - a->map[i] &= ~b->map[i]; + a->map[i] &= b->map[i]; } diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h index 36282af1c..ffa3c42d7 100644 --- a/src/util/virbitmap.h +++ b/src/util/virbitmap.h @@ -143,7 +143,7 @@ bool virBitmapOverlaps(virBitmapPtr b1, virBitmapPtr b2) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -void virBitmapSubtract(virBitmapPtr a, virBitmapPtr b) +void virBitmapIntersect(virBitmapPtr a, virBitmapPtr b) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); #endif diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index e5305d022..882c71544 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -589,7 +589,7 @@ test11(const void *opaque) virBitmapParse(data->res, &resmap, 256) < 0) goto cleanup; - virBitmapSubtract(amap, bmap); + virBitmapIntersect(amap, bmap); if (!virBitmapEqual(amap, resmap)) { fprintf(stderr, "\n bitmap subtraction failed: '%s'-'%s'!='%s'\n", @@ -700,13 +700,13 @@ mymain(void) ret = -1; virTestCounterReset("test11-"); - TESTBINARYOP("0", "0", "0,^0", test11); - TESTBINARYOP("0-3", "0", "1-3", test11); - TESTBINARYOP("0-3", "0,3", "1-2", test11); + TESTBINARYOP("0", "0", "0", test11); + TESTBINARYOP("0-3", "0", "0", test11); + TESTBINARYOP("0-3", "0,3", "0,3", test11); TESTBINARYOP("0,^0", "0", "0,^0", test11); - TESTBINARYOP("0-3", "0-3", "0,^0", test11); - TESTBINARYOP("0-3", "0,^0", "0-3", test11); - TESTBINARYOP("0,2", "1,3", "0,2", test11); + TESTBINARYOP("0-3", "0-3", "0-3", test11); + TESTBINARYOP("0-3", "0,^0", "0,^0", test11); + TESTBINARYOP("0,2", "1,3", "0,^0", test11); if (virTestRun("test12", test12, NULL) < 0) ret = -1; -- 2.12.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list