Commit f2f376a9 authored by David Renshaw's avatar David Renshaw

fix some but not all errors reported by -DCAPNP_DEBUG_TYPES

parent fbb5f0f1
......@@ -1812,13 +1812,14 @@ struct WireHelpers {
// List of data.
ref->listRef.set(value.elementSize, value.elementCount);
auto wholeByteSize = value.elementCount * value.step / BITS_PER_BYTE;
auto wholeByteSize = upgradeBound<uint64_t>(value.elementCount) * value.step / BITS_PER_BYTE;
copyMemory(reinterpret_cast<byte*>(ptr), value.ptr, wholeByteSize);
auto leftoverBits = value.elementCount * value.step % BITS_PER_BYTE;
if (leftoverBits > 0) {
auto leftoverBits =
(upgradeBound<uint64_t>(value.elementCount) * value.step) % (BYTES * BITS_PER_BYTE);
if (leftoverBits > ZERO * BITS) {
// We need to copy a partial byte.
uint8_t mask = (1 << leftoverBits) - 1;
(reinterpret_cast<byte*>(ptr))[wholeByteSize] = mask & value.ptr[wholeByteSize];
uint8_t mask = (1 << leftoverBits / BITS) - 1;
*((reinterpret_cast<byte*>(ptr)) + wholeByteSize) = mask & *(value.ptr + wholeByteSize);
}
}
......@@ -3162,9 +3163,10 @@ bool ListReader::isCanonical(const word **readHead, const WirePointer *ref) {
auto byteReadHead = reinterpret_cast<const uint8_t*>(*readHead) + truncatedByteSize;
auto readHeadEnd = *readHead + WireHelpers::roundBitsUpToWords(bitSize);
auto leftoverBits = bitSize % 8;
if (leftoverBits > 0) {
uint8_t mask = ~((1 << leftoverBits) - 1);
auto leftoverBits = bitSize % (BYTES * BITS_PER_BYTE);
if (leftoverBits > ZERO * BITS) {
auto mask = ~((1 << (leftoverBits / BITS)) - 1);
if (mask & *byteReadHead) {
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment