Refactored unsigned long negations

Replaced two instances of negating an unsigned long, which was
resulting in aborts from unsigned integer sanitization with the
equivalent logical not-add 1.

Bug: 25884483
Change-Id: Ic7498e0af638dcd438ce69803021d3cdc3acd4f6
This commit is contained in:
Dan Austin
2015-12-11 16:33:23 -08:00
parent 3871933e15
commit 10fbe684fb

View File

@@ -90,13 +90,13 @@ void SparseBitSet::initFromRanges(const uint32_t* ranges, size_t nRanges) {
size_t nElements = (end - (start & ~kElMask) + kElMask) >> kLogBitsPerEl;
if (nElements == 1) {
mBitmaps[index] |= (kElAllOnes >> (start & kElMask)) &
(kElAllOnes << ((-end) & kElMask));
(kElAllOnes << ((~end + 1) & kElMask));
} else {
mBitmaps[index] |= kElAllOnes >> (start & kElMask);
for (size_t j = 1; j < nElements - 1; j++) {
mBitmaps[index + j] = kElAllOnes;
}
mBitmaps[index + nElements - 1] |= kElAllOnes << ((-end) & kElMask);
mBitmaps[index + nElements - 1] |= kElAllOnes << ((~end + 1) & kElMask);
}
for (size_t j = startPage + 1; j < endPage + 1; j++) {
mIndices[j] = (currentPage++) << (kLogValuesPerPage - kLogBitsPerEl);