diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 36caf6fbfd..a35ad0f859 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1298,6 +1298,7 @@ virBitmapEqual; virBitmapFormat; virBitmapFree; virBitmapGetBit; +virBitmapIntersect; virBitmapIsAllClear; virBitmapIsAllSet; virBitmapIsBitSet; @@ -1318,7 +1319,6 @@ virBitmapSetBit; virBitmapSetBitExpand; virBitmapSize; virBitmapString; -virBitmapSubtract; virBitmapToData; virBitmapToDataBuf; diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index eac63d9974..a5077fe7c8 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 36282af1cd..ffa3c42d79 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 e5305d0223..76005117e7 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -589,10 +589,11 @@ 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", + fprintf(stderr, + "\n bitmap intersection failed: intersect('%s','%s') !='%s'\n", data->a, data->b, data->res); goto cleanup; } @@ -700,13 +701,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;