Commit 6d346575 authored by Kenton Varda's avatar Kenton Varda

CHECK -> ASSERT

parent 20272ec5
...@@ -168,7 +168,7 @@ kj::ArrayPtr<const kj::ArrayPtr<const word>> BuilderArena::getSegmentsForOutput( ...@@ -168,7 +168,7 @@ kj::ArrayPtr<const kj::ArrayPtr<const word>> BuilderArena::getSegmentsForOutput(
return kj::arrayPtr(&segment0ForOutput, 1); return kj::arrayPtr(&segment0ForOutput, 1);
} }
} else { } else {
DCHECK(moreSegments->forOutput.size() == moreSegments->builders.size() + 1, DASSERT(moreSegments->forOutput.size() == moreSegments->builders.size() + 1,
"moreSegments->forOutput wasn't resized correctly when the last builder was added.", "moreSegments->forOutput wasn't resized correctly when the last builder was added.",
moreSegments->forOutput.size(), moreSegments->builders.size()); moreSegments->forOutput.size(), moreSegments->builders.size());
...@@ -201,7 +201,7 @@ SegmentReader* BuilderArena::tryGetSegment(SegmentId id) { ...@@ -201,7 +201,7 @@ SegmentReader* BuilderArena::tryGetSegment(SegmentId id) {
} }
void BuilderArena::reportReadLimitReached() { void BuilderArena::reportReadLimitReached() {
FAIL_RECOVERABLE_CHECK( FAIL_RECOVERABLE_ASSERT(
"Read limit reached for BuilderArena, but it should have been unlimited.") {} "Read limit reached for BuilderArena, but it should have been unlimited.") {}
} }
......
...@@ -128,8 +128,8 @@ void TextBlob::allocate(size_t textSize, size_t branchCount, ...@@ -128,8 +128,8 @@ void TextBlob::allocate(size_t textSize, size_t branchCount,
} }
void TextBlob::fill(char* textPos, Branch* branchesPos) { void TextBlob::fill(char* textPos, Branch* branchesPos) {
CHECK(textPos == text.end(), textPos - text.end()); ASSERT(textPos == text.end(), textPos - text.end());
CHECK(branchesPos == branches.end(), branchesPos - branches.end()); ASSERT(branchesPos == branches.end(), branchesPos - branches.end());
} }
template <typename First, typename... Rest> template <typename First, typename... Rest>
......
...@@ -83,7 +83,7 @@ internal::FieldSize elementSizeFor(schema::Type::Body::Which elementType) { ...@@ -83,7 +83,7 @@ internal::FieldSize elementSizeFor(schema::Type::Body::Which elementType) {
case schema::Type::Body::ENUM_TYPE: return internal::FieldSize::TWO_BYTES; case schema::Type::Body::ENUM_TYPE: return internal::FieldSize::TWO_BYTES;
case schema::Type::Body::STRUCT_TYPE: return internal::FieldSize::INLINE_COMPOSITE; case schema::Type::Body::STRUCT_TYPE: return internal::FieldSize::INLINE_COMPOSITE;
case schema::Type::Body::INTERFACE_TYPE: return internal::FieldSize::POINTER; case schema::Type::Body::INTERFACE_TYPE: return internal::FieldSize::POINTER;
case schema::Type::Body::OBJECT_TYPE: FAIL_CHECK("List(Object) not supported."); break; case schema::Type::Body::OBJECT_TYPE: FAIL_ASSERT("List(Object) not supported."); break;
} }
// Unknown type. Treat it as zero-size. // Unknown type. Treat it as zero-size.
...@@ -255,7 +255,7 @@ Data::Builder DynamicUnion::Builder::initObjectAsData(Text::Reader name, uint si ...@@ -255,7 +255,7 @@ Data::Builder DynamicUnion::Builder::initObjectAsData(Text::Reader name, uint si
StructSchema::Member DynamicUnion::Builder::checkIsObject() { StructSchema::Member DynamicUnion::Builder::checkIsObject() {
KJ_IF_MAYBE(w, which()) { KJ_IF_MAYBE(w, which()) {
CHECK(w->getProto().getBody().which() == schema::StructNode::Member::Body::FIELD_MEMBER, ASSERT(w->getProto().getBody().which() == schema::StructNode::Member::Body::FIELD_MEMBER,
"Unsupported union member type."); "Unsupported union member type.");
REQUIRE(w->getProto().getBody().getFieldMember().getType().getBody().which() == REQUIRE(w->getProto().getBody().getFieldMember().getType().getBody().which() ==
schema::Type::Body::OBJECT_TYPE, "Expected Object."); schema::Type::Body::OBJECT_TYPE, "Expected Object.");
...@@ -456,7 +456,7 @@ DynamicStruct::Builder DynamicStruct::Builder::getObject( ...@@ -456,7 +456,7 @@ DynamicStruct::Builder DynamicStruct::Builder::getObject(
} }
} }
FAIL_CHECK("switch() missing case.", (uint)member.getProto().getBody().which()); FAIL_ASSERT("switch() missing case.", (uint)member.getProto().getBody().which());
return DynamicStruct::Builder(); return DynamicStruct::Builder();
} }
DynamicList::Builder DynamicStruct::Builder::getObject( DynamicList::Builder DynamicStruct::Builder::getObject(
...@@ -475,7 +475,7 @@ DynamicList::Builder DynamicStruct::Builder::getObject( ...@@ -475,7 +475,7 @@ DynamicList::Builder DynamicStruct::Builder::getObject(
} }
} }
FAIL_CHECK("switch() missing case.", (uint)member.getProto().getBody().which()); FAIL_ASSERT("switch() missing case.", (uint)member.getProto().getBody().which());
return DynamicList::Builder(); return DynamicList::Builder();
} }
Text::Builder DynamicStruct::Builder::getObjectAsText(StructSchema::Member member) { Text::Builder DynamicStruct::Builder::getObjectAsText(StructSchema::Member member) {
...@@ -493,7 +493,7 @@ Text::Builder DynamicStruct::Builder::getObjectAsText(StructSchema::Member membe ...@@ -493,7 +493,7 @@ Text::Builder DynamicStruct::Builder::getObjectAsText(StructSchema::Member membe
} }
} }
FAIL_CHECK("switch() missing case.", (uint)member.getProto().getBody().which()); FAIL_ASSERT("switch() missing case.", (uint)member.getProto().getBody().which());
return Text::Builder(); return Text::Builder();
} }
Data::Builder DynamicStruct::Builder::getObjectAsData(StructSchema::Member member) { Data::Builder DynamicStruct::Builder::getObjectAsData(StructSchema::Member member) {
...@@ -511,7 +511,7 @@ Data::Builder DynamicStruct::Builder::getObjectAsData(StructSchema::Member membe ...@@ -511,7 +511,7 @@ Data::Builder DynamicStruct::Builder::getObjectAsData(StructSchema::Member membe
} }
} }
FAIL_CHECK("switch() missing case.", (uint)member.getProto().getBody().which()); FAIL_ASSERT("switch() missing case.", (uint)member.getProto().getBody().which());
return Data::Builder(); return Data::Builder();
} }
...@@ -531,7 +531,7 @@ DynamicStruct::Builder DynamicStruct::Builder::initObject( ...@@ -531,7 +531,7 @@ DynamicStruct::Builder DynamicStruct::Builder::initObject(
} }
} }
FAIL_CHECK("switch() missing case.", (uint)member.getProto().getBody().which()); FAIL_ASSERT("switch() missing case.", (uint)member.getProto().getBody().which());
return DynamicStruct::Builder(); return DynamicStruct::Builder();
} }
DynamicList::Builder DynamicStruct::Builder::initObject( DynamicList::Builder DynamicStruct::Builder::initObject(
...@@ -550,7 +550,7 @@ DynamicList::Builder DynamicStruct::Builder::initObject( ...@@ -550,7 +550,7 @@ DynamicList::Builder DynamicStruct::Builder::initObject(
} }
} }
FAIL_CHECK("switch() missing case.", (uint)member.getProto().getBody().which()); FAIL_ASSERT("switch() missing case.", (uint)member.getProto().getBody().which());
return DynamicList::Builder(); return DynamicList::Builder();
} }
Text::Builder DynamicStruct::Builder::initObjectAsText(StructSchema::Member member, uint size) { Text::Builder DynamicStruct::Builder::initObjectAsText(StructSchema::Member member, uint size) {
...@@ -568,7 +568,7 @@ Text::Builder DynamicStruct::Builder::initObjectAsText(StructSchema::Member memb ...@@ -568,7 +568,7 @@ Text::Builder DynamicStruct::Builder::initObjectAsText(StructSchema::Member memb
} }
} }
FAIL_CHECK("switch() missing case.", (uint)member.getProto().getBody().which()); FAIL_ASSERT("switch() missing case.", (uint)member.getProto().getBody().which());
return Text::Builder(); return Text::Builder();
} }
Data::Builder DynamicStruct::Builder::initObjectAsData(StructSchema::Member member, uint size) { Data::Builder DynamicStruct::Builder::initObjectAsData(StructSchema::Member member, uint size) {
...@@ -586,7 +586,7 @@ Data::Builder DynamicStruct::Builder::initObjectAsData(StructSchema::Member memb ...@@ -586,7 +586,7 @@ Data::Builder DynamicStruct::Builder::initObjectAsData(StructSchema::Member memb
} }
} }
FAIL_CHECK("switch() missing case.", (uint)member.getProto().getBody().which()); FAIL_ASSERT("switch() missing case.", (uint)member.getProto().getBody().which());
return Data::Builder(); return Data::Builder();
} }
...@@ -723,7 +723,7 @@ DynamicValue::Reader DynamicStruct::Reader::getImpl( ...@@ -723,7 +723,7 @@ DynamicValue::Reader DynamicStruct::Reader::getImpl(
} }
case schema::Type::Body::INTERFACE_TYPE: case schema::Type::Body::INTERFACE_TYPE:
FAIL_CHECK("Interfaces not yet implemented."); FAIL_ASSERT("Interfaces not yet implemented.");
break; break;
} }
...@@ -731,7 +731,7 @@ DynamicValue::Reader DynamicStruct::Reader::getImpl( ...@@ -731,7 +731,7 @@ DynamicValue::Reader DynamicStruct::Reader::getImpl(
} }
} }
FAIL_CHECK("switch() missing case.", (uint)member.getProto().getBody().which()); FAIL_ASSERT("switch() missing case.", (uint)member.getProto().getBody().which());
return nullptr; return nullptr;
} }
...@@ -826,7 +826,7 @@ DynamicValue::Builder DynamicStruct::Builder::getImpl( ...@@ -826,7 +826,7 @@ DynamicValue::Builder DynamicStruct::Builder::getImpl(
} }
case schema::Type::Body::INTERFACE_TYPE: case schema::Type::Body::INTERFACE_TYPE:
FAIL_CHECK("Interfaces not yet implemented."); FAIL_ASSERT("Interfaces not yet implemented.");
break; break;
} }
...@@ -834,7 +834,7 @@ DynamicValue::Builder DynamicStruct::Builder::getImpl( ...@@ -834,7 +834,7 @@ DynamicValue::Builder DynamicStruct::Builder::getImpl(
} }
} }
FAIL_CHECK("switch() missing case.", (uint)member.getProto().getBody().which()); FAIL_ASSERT("switch() missing case.", (uint)member.getProto().getBody().which());
return nullptr; return nullptr;
} }
DynamicStruct::Builder DynamicStruct::Builder::getObjectImpl( DynamicStruct::Builder DynamicStruct::Builder::getObjectImpl(
...@@ -963,7 +963,7 @@ void DynamicStruct::Builder::setImpl( ...@@ -963,7 +963,7 @@ void DynamicStruct::Builder::setImpl(
} }
case schema::Type::Body::INTERFACE_TYPE: case schema::Type::Body::INTERFACE_TYPE:
FAIL_CHECK("Interfaces not yet implemented."); FAIL_ASSERT("Interfaces not yet implemented.");
return; return;
} }
...@@ -972,7 +972,7 @@ void DynamicStruct::Builder::setImpl( ...@@ -972,7 +972,7 @@ void DynamicStruct::Builder::setImpl(
} }
} }
FAIL_CHECK("switch() missing case.", (uint)member.getProto().getBody().which()); FAIL_ASSERT("switch() missing case.", (uint)member.getProto().getBody().which());
} }
DynamicValue::Builder DynamicStruct::Builder::initImpl( DynamicValue::Builder DynamicStruct::Builder::initImpl(
...@@ -1109,7 +1109,7 @@ DynamicValue::Reader DynamicList::Reader::operator[](uint index) const { ...@@ -1109,7 +1109,7 @@ DynamicValue::Reader DynamicList::Reader::operator[](uint index) const {
reader.getObjectElement(index * ELEMENTS))); reader.getObjectElement(index * ELEMENTS)));
case schema::Type::Body::INTERFACE_TYPE: case schema::Type::Body::INTERFACE_TYPE:
FAIL_RECOVERABLE_CHECK("Interfaces not implemented.") {} FAIL_RECOVERABLE_ASSERT("Interfaces not implemented.") {}
return nullptr; return nullptr;
} }
...@@ -1167,11 +1167,11 @@ DynamicValue::Builder DynamicList::Builder::operator[](uint index) const { ...@@ -1167,11 +1167,11 @@ DynamicValue::Builder DynamicList::Builder::operator[](uint index) const {
schema.getEnumElementType(), builder.getDataElement<uint16_t>(index * ELEMENTS))); schema.getEnumElementType(), builder.getDataElement<uint16_t>(index * ELEMENTS)));
case schema::Type::Body::OBJECT_TYPE: case schema::Type::Body::OBJECT_TYPE:
FAIL_CHECK("List(Object) not supported."); FAIL_ASSERT("List(Object) not supported.");
return nullptr; return nullptr;
case schema::Type::Body::INTERFACE_TYPE: case schema::Type::Body::INTERFACE_TYPE:
FAIL_RECOVERABLE_CHECK("Interfaces not implemented.") {} FAIL_RECOVERABLE_ASSERT("Interfaces not implemented.") {}
return nullptr; return nullptr;
} }
...@@ -1219,7 +1219,7 @@ void DynamicList::Builder::set(uint index, DynamicValue::Reader value) { ...@@ -1219,7 +1219,7 @@ void DynamicList::Builder::set(uint index, DynamicValue::Reader value) {
// Not supported for the same reason List<struct> doesn't support it -- the space for the // Not supported for the same reason List<struct> doesn't support it -- the space for the
// element is already allocated, and if it's smaller than the input value the copy would // element is already allocated, and if it's smaller than the input value the copy would
// have to be lossy. // have to be lossy.
FAIL_RECOVERABLE_CHECK("DynamicList of structs does not support set()."); FAIL_RECOVERABLE_ASSERT("DynamicList of structs does not support set().");
return; return;
case schema::Type::Body::ENUM_TYPE: { case schema::Type::Body::ENUM_TYPE: {
...@@ -1240,11 +1240,11 @@ void DynamicList::Builder::set(uint index, DynamicValue::Reader value) { ...@@ -1240,11 +1240,11 @@ void DynamicList::Builder::set(uint index, DynamicValue::Reader value) {
} }
case schema::Type::Body::OBJECT_TYPE: case schema::Type::Body::OBJECT_TYPE:
FAIL_RECOVERABLE_CHECK("List(Object) not supported."); FAIL_RECOVERABLE_ASSERT("List(Object) not supported.");
return; return;
case schema::Type::Body::INTERFACE_TYPE: case schema::Type::Body::INTERFACE_TYPE:
FAIL_RECOVERABLE_CHECK("Interfaces not implemented.") {} FAIL_RECOVERABLE_ASSERT("Interfaces not implemented.") {}
return; return;
} }
...@@ -1296,7 +1296,7 @@ DynamicValue::Builder DynamicList::Builder::init(uint index, uint size) { ...@@ -1296,7 +1296,7 @@ DynamicValue::Builder DynamicList::Builder::init(uint index, uint size) {
} }
case schema::Type::Body::OBJECT_TYPE: { case schema::Type::Body::OBJECT_TYPE: {
FAIL_CHECK("List(Object) not supported."); FAIL_ASSERT("List(Object) not supported.");
return nullptr; return nullptr;
} }
} }
...@@ -1332,10 +1332,10 @@ DynamicValue::Reader DynamicValue::Builder::asReader() { ...@@ -1332,10 +1332,10 @@ DynamicValue::Reader DynamicValue::Builder::asReader() {
case ENUM: return Reader(enumValue); case ENUM: return Reader(enumValue);
case STRUCT: return Reader(structValue.asReader()); case STRUCT: return Reader(structValue.asReader());
case UNION: return Reader(unionValue.asReader()); case UNION: return Reader(unionValue.asReader());
case INTERFACE: FAIL_CHECK("Interfaces not implemented."); return Reader(); case INTERFACE: FAIL_ASSERT("Interfaces not implemented."); return Reader();
case OBJECT: return Reader(objectValue); case OBJECT: return Reader(objectValue);
} }
FAIL_CHECK("Missing switch case."); FAIL_ASSERT("Missing switch case.");
return Reader(); return Reader();
} }
......
...@@ -279,7 +279,7 @@ UnionState initUnion(Func&& initializer) { ...@@ -279,7 +279,7 @@ UnionState initUnion(Func&& initializer) {
initializer(builder.getRoot<StructType>()); initializer(builder.getRoot<StructType>());
kj::ArrayPtr<const word> segment = builder.getSegmentsForOutput()[0]; kj::ArrayPtr<const word> segment = builder.getSegmentsForOutput()[0];
CHECK(segment.size() > 2, segment.size()); ASSERT(segment.size() > 2, segment.size());
// Find the offset of the first set bit after the union discriminants. // Find the offset of the first set bit after the union discriminants.
int offset = 0; int offset = 0;
......
...@@ -338,7 +338,7 @@ struct WireHelpers { ...@@ -338,7 +338,7 @@ struct WireHelpers {
break; break;
} }
case WirePointer::RESERVED_3: case WirePointer::RESERVED_3:
FAIL_RECOVERABLE_CHECK("Don't know how to handle RESERVED_3.") {} FAIL_RECOVERABLE_ASSERT("Don't know how to handle RESERVED_3.") {}
break; break;
} }
} }
...@@ -380,7 +380,7 @@ struct WireHelpers { ...@@ -380,7 +380,7 @@ struct WireHelpers {
case FieldSize::INLINE_COMPOSITE: { case FieldSize::INLINE_COMPOSITE: {
WirePointer* elementTag = reinterpret_cast<WirePointer*>(ptr); WirePointer* elementTag = reinterpret_cast<WirePointer*>(ptr);
CHECK(elementTag->kind() == WirePointer::STRUCT, ASSERT(elementTag->kind() == WirePointer::STRUCT,
"Don't know how to handle non-STRUCT inline composite."); "Don't know how to handle non-STRUCT inline composite.");
WordCount dataSize = elementTag->structRef.dataSize.get(); WordCount dataSize = elementTag->structRef.dataSize.get();
WirePointerCount pointerCount = elementTag->structRef.ptrCount.get(); WirePointerCount pointerCount = elementTag->structRef.ptrCount.get();
...@@ -404,10 +404,10 @@ struct WireHelpers { ...@@ -404,10 +404,10 @@ struct WireHelpers {
break; break;
} }
case WirePointer::FAR: case WirePointer::FAR:
FAIL_RECOVERABLE_CHECK("Unexpected FAR pointer.") {} FAIL_RECOVERABLE_ASSERT("Unexpected FAR pointer.") {}
break; break;
case WirePointer::RESERVED_3: case WirePointer::RESERVED_3:
FAIL_RECOVERABLE_CHECK("Don't know how to handle RESERVED_3.") {} FAIL_RECOVERABLE_ASSERT("Don't know how to handle RESERVED_3.") {}
break; break;
} }
} }
...@@ -538,7 +538,7 @@ struct WireHelpers { ...@@ -538,7 +538,7 @@ struct WireHelpers {
break; break;
} }
case WirePointer::FAR: case WirePointer::FAR:
FAIL_RECOVERABLE_CHECK("Unexpected FAR pointer.") { FAIL_RECOVERABLE_ASSERT("Unexpected FAR pointer.") {
break; break;
} }
break; break;
...@@ -640,7 +640,7 @@ struct WireHelpers { ...@@ -640,7 +640,7 @@ struct WireHelpers {
const word* srcElement = srcPtr + POINTER_SIZE_IN_WORDS; const word* srcElement = srcPtr + POINTER_SIZE_IN_WORDS;
word* dstElement = dstPtr + POINTER_SIZE_IN_WORDS; word* dstElement = dstPtr + POINTER_SIZE_IN_WORDS;
CHECK(srcTag->kind() == WirePointer::STRUCT, ASSERT(srcTag->kind() == WirePointer::STRUCT,
"INLINE_COMPOSITE of lists is not yet supported."); "INLINE_COMPOSITE of lists is not yet supported.");
uint n = srcTag->inlineCompositeListElementCount() / ELEMENTS; uint n = srcTag->inlineCompositeListElementCount() / ELEMENTS;
...@@ -689,7 +689,7 @@ struct WireHelpers { ...@@ -689,7 +689,7 @@ struct WireHelpers {
// Darn, need a double-far. // Darn, need a double-far.
SegmentBuilder* farSegment = srcSegment->getArena()->getSegmentWithAvailable(2 * WORDS); SegmentBuilder* farSegment = srcSegment->getArena()->getSegmentWithAvailable(2 * WORDS);
landingPad = reinterpret_cast<WirePointer*>(farSegment->allocate(2 * WORDS)); landingPad = reinterpret_cast<WirePointer*>(farSegment->allocate(2 * WORDS));
DCHECK(landingPad != nullptr, DASSERT(landingPad != nullptr,
"getSegmentWithAvailable() returned segment without space available."); "getSegmentWithAvailable() returned segment without space available.");
landingPad[0].setFar(false, srcSegment->getOffsetTo(src->target())); landingPad[0].setFar(false, srcSegment->getOffsetTo(src->target()));
...@@ -915,7 +915,7 @@ struct WireHelpers { ...@@ -915,7 +915,7 @@ struct WireHelpers {
break; break;
case FieldSize::INLINE_COMPOSITE: case FieldSize::INLINE_COMPOSITE:
FAIL_CHECK("Can't get here."); FAIL_ASSERT("Can't get here.");
break; break;
} }
...@@ -1148,11 +1148,11 @@ struct WireHelpers { ...@@ -1148,11 +1148,11 @@ struct WireHelpers {
} else { } else {
// If oldSize were POINTER or EIGHT_BYTES then the preferred size must be // If oldSize were POINTER or EIGHT_BYTES then the preferred size must be
// INLINE_COMPOSITE because any other compatible size would not require an upgrade. // INLINE_COMPOSITE because any other compatible size would not require an upgrade.
CHECK(oldSize < FieldSize::EIGHT_BYTES); ASSERT(oldSize < FieldSize::EIGHT_BYTES);
// If the preferred size were BIT then oldSize must be VOID, but we handled that case // If the preferred size were BIT then oldSize must be VOID, but we handled that case
// above. // above.
CHECK(elementSize.preferredListEncoding >= FieldSize::BIT); ASSERT(elementSize.preferredListEncoding >= FieldSize::BIT);
// OK, so the expected list elements are all data and between 1 byte and 1 word each, // OK, so the expected list elements are all data and between 1 byte and 1 word each,
// and the old element are data between 1 bit and 4 bytes. We're upgrading from one // and the old element are data between 1 bit and 4 bytes. We're upgrading from one
...@@ -1364,7 +1364,7 @@ struct WireHelpers { ...@@ -1364,7 +1364,7 @@ struct WireHelpers {
case 32: elementSize = FieldSize::FOUR_BYTES; break; case 32: elementSize = FieldSize::FOUR_BYTES; break;
case 64: elementSize = FieldSize::EIGHT_BYTES; break; case 64: elementSize = FieldSize::EIGHT_BYTES; break;
default: default:
FAIL_CHECK("invalid list step size", value.step * ELEMENTS / BITS); FAIL_ASSERT("invalid list step size", value.step * ELEMENTS / BITS);
break; break;
} }
...@@ -2142,7 +2142,7 @@ StructReader ListReader::getStructElement(ElementCount index) const { ...@@ -2142,7 +2142,7 @@ StructReader ListReader::getStructElement(ElementCount index) const {
reinterpret_cast<const WirePointer*>(structData + structDataSize / BITS_PER_BYTE); reinterpret_cast<const WirePointer*>(structData + structDataSize / BITS_PER_BYTE);
// This check should pass if there are no bugs in the list pointer validation code. // This check should pass if there are no bugs in the list pointer validation code.
DCHECK(structPointerCount == 0 * POINTERS || DASSERT(structPointerCount == 0 * POINTERS ||
(uintptr_t)structPointers % sizeof(WirePointer) == 0, (uintptr_t)structPointers % sizeof(WirePointer) == 0,
"Pointer segment of struct list element not aligned."); "Pointer segment of struct list element not aligned.");
...@@ -2153,7 +2153,7 @@ StructReader ListReader::getStructElement(ElementCount index) const { ...@@ -2153,7 +2153,7 @@ StructReader ListReader::getStructElement(ElementCount index) const {
} }
static const WirePointer* checkAlignment(const void* ptr) { static const WirePointer* checkAlignment(const void* ptr) {
DCHECK((uintptr_t)ptr % sizeof(WirePointer) == 0, DASSERT((uintptr_t)ptr % sizeof(WirePointer) == 0,
"Pointer segment of struct list element not aligned."); "Pointer segment of struct list element not aligned.");
return reinterpret_cast<const WirePointer*>(ptr); return reinterpret_cast<const WirePointer*>(ptr);
} }
......
...@@ -80,10 +80,10 @@ internal::SegmentBuilder* MessageBuilder::getRootSegment() { ...@@ -80,10 +80,10 @@ internal::SegmentBuilder* MessageBuilder::getRootSegment() {
WordCount ptrSize = 1 * POINTERS * WORDS_PER_POINTER; WordCount ptrSize = 1 * POINTERS * WORDS_PER_POINTER;
internal::SegmentBuilder* segment = arena()->getSegmentWithAvailable(ptrSize); internal::SegmentBuilder* segment = arena()->getSegmentWithAvailable(ptrSize);
CHECK(segment->getSegmentId() == internal::SegmentId(0), ASSERT(segment->getSegmentId() == internal::SegmentId(0),
"First allocated word of new arena was not in segment ID 0."); "First allocated word of new arena was not in segment ID 0.");
word* location = segment->allocate(ptrSize); word* location = segment->allocate(ptrSize);
CHECK(location == segment->getPtrUnchecked(0 * WORDS), ASSERT(location == segment->getPtrUnchecked(0 * WORDS),
"First allocated word of new arena was not the first word in its segment."); "First allocated word of new arena was not the first word in its segment.");
return segment; return segment;
} }
...@@ -161,7 +161,7 @@ MallocMessageBuilder::~MallocMessageBuilder() { ...@@ -161,7 +161,7 @@ MallocMessageBuilder::~MallocMessageBuilder() {
// Must zero first segment. // Must zero first segment.
kj::ArrayPtr<const kj::ArrayPtr<const word>> segments = getSegmentsForOutput(); kj::ArrayPtr<const kj::ArrayPtr<const word>> segments = getSegmentsForOutput();
if (segments.size() > 0) { if (segments.size() > 0) {
CHECK(segments[0].begin() == firstSegment, ASSERT(segments[0].begin() == firstSegment,
"First segment in getSegmentsForOutput() is not the first segment allocated?"); "First segment in getSegmentsForOutput() is not the first segment allocated?");
memset(firstSegment, 0, segments[0].size() * sizeof(word)); memset(firstSegment, 0, segments[0].size() * sizeof(word));
} }
......
...@@ -119,7 +119,7 @@ public: ...@@ -119,7 +119,7 @@ public:
for (auto& dep: dependencies) { for (auto& dep: dependencies) {
result[pos++] = dep.second; result[pos++] = dep.second;
} }
DCHECK(pos == *count); DASSERT(pos == *count);
return result; return result;
} }
...@@ -131,7 +131,7 @@ public: ...@@ -131,7 +131,7 @@ public:
for (auto& member: members) { for (auto& member: members) {
result[pos++] = internal::RawSchema::MemberInfo(member.first.first, member.second); result[pos++] = internal::RawSchema::MemberInfo(member.first.first, member.second);
} }
DCHECK(pos == *count); DASSERT(pos == *count);
return result; return result;
} }
...@@ -934,7 +934,7 @@ private: ...@@ -934,7 +934,7 @@ private:
schema::Value::Reader replacement) { schema::Value::Reader replacement) {
// Note that we test default compatibility only after testing type compatibility, and default // Note that we test default compatibility only after testing type compatibility, and default
// values have already been validated as matching their types, so this should pass. // values have already been validated as matching their types, so this should pass.
RECOVERABLE_CHECK(value.getBody().which() == replacement.getBody().which()) { RECOVERABLE_ASSERT(value.getBody().which() == replacement.getBody().which()) {
compatibility = INCOMPATIBLE; compatibility = INCOMPATIBLE;
return; return;
} }
......
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
} }
size_t read(void* buffer, size_t minBytes, size_t maxBytes) override { size_t read(void* buffer, size_t minBytes, size_t maxBytes) override {
CHECK(maxBytes <= data.size() - readPos, "Overran end of stream."); ASSERT(maxBytes <= data.size() - readPos, "Overran end of stream.");
size_t amount = std::min(maxBytes, std::max(minBytes, preferredReadSize)); size_t amount = std::min(maxBytes, std::max(minBytes, preferredReadSize));
memcpy(buffer, data.data() + readPos, amount); memcpy(buffer, data.data() + readPos, amount);
readPos += amount; readPos += amount;
...@@ -70,7 +70,7 @@ public: ...@@ -70,7 +70,7 @@ public:
} }
void skip(size_t bytes) override { void skip(size_t bytes) override {
CHECK(bytes <= data.size() - readPos, "Overran end of stream."); ASSERT(bytes <= data.size() - readPos, "Overran end of stream.");
readPos += bytes; readPos += bytes;
} }
......
...@@ -66,7 +66,7 @@ size_t PackedInputStream::read(void* dst, size_t minBytes, size_t maxBytes) { ...@@ -66,7 +66,7 @@ size_t PackedInputStream::read(void* dst, size_t minBytes, size_t maxBytes) {
for (;;) { for (;;) {
uint8_t tag; uint8_t tag;
DCHECK((out - reinterpret_cast<uint8_t*>(dst)) % sizeof(word) == 0, DASSERT((out - reinterpret_cast<uint8_t*>(dst)) % sizeof(word) == 0,
"Output pointer should always be aligned here."); "Output pointer should always be aligned here.");
if (BUFFER_REMAINING < 10) { if (BUFFER_REMAINING < 10) {
...@@ -122,7 +122,7 @@ size_t PackedInputStream::read(void* dst, size_t minBytes, size_t maxBytes) { ...@@ -122,7 +122,7 @@ size_t PackedInputStream::read(void* dst, size_t minBytes, size_t maxBytes) {
} }
if (tag == 0) { if (tag == 0) {
DCHECK(BUFFER_REMAINING > 0, "Should always have non-empty buffer here."); DASSERT(BUFFER_REMAINING > 0, "Should always have non-empty buffer here.");
uint runLength = *in++ * sizeof(word); uint runLength = *in++ * sizeof(word);
...@@ -134,7 +134,7 @@ size_t PackedInputStream::read(void* dst, size_t minBytes, size_t maxBytes) { ...@@ -134,7 +134,7 @@ size_t PackedInputStream::read(void* dst, size_t minBytes, size_t maxBytes) {
out += runLength; out += runLength;
} else if (tag == 0xffu) { } else if (tag == 0xffu) {
DCHECK(BUFFER_REMAINING > 0, "Should always have non-empty buffer here."); DASSERT(BUFFER_REMAINING > 0, "Should always have non-empty buffer here.");
uint runLength = *in++ * sizeof(word); uint runLength = *in++ * sizeof(word);
...@@ -177,8 +177,8 @@ size_t PackedInputStream::read(void* dst, size_t minBytes, size_t maxBytes) { ...@@ -177,8 +177,8 @@ size_t PackedInputStream::read(void* dst, size_t minBytes, size_t maxBytes) {
} }
} }
FAIL_CHECK("Can't get here."); FAIL_ASSERT("Can't get here.");
return 0; // GCC knows FAIL_CHECK doesn't return, but Eclipse CDT still warns... return 0; // GCC knows FAIL_ASSERT doesn't return, but Eclipse CDT still warns...
#undef REFRESH_BUFFER #undef REFRESH_BUFFER
} }
...@@ -248,7 +248,7 @@ void PackedInputStream::skip(size_t bytes) { ...@@ -248,7 +248,7 @@ void PackedInputStream::skip(size_t bytes) {
} }
if (tag == 0) { if (tag == 0) {
DCHECK(BUFFER_REMAINING > 0, "Should always have non-empty buffer here."); DASSERT(BUFFER_REMAINING > 0, "Should always have non-empty buffer here.");
uint runLength = *in++ * sizeof(word); uint runLength = *in++ * sizeof(word);
...@@ -260,7 +260,7 @@ void PackedInputStream::skip(size_t bytes) { ...@@ -260,7 +260,7 @@ void PackedInputStream::skip(size_t bytes) {
bytes -= runLength; bytes -= runLength;
} else if (tag == 0xffu) { } else if (tag == 0xffu) {
DCHECK(BUFFER_REMAINING > 0, "Should always have non-empty buffer here."); DASSERT(BUFFER_REMAINING > 0, "Should always have non-empty buffer here.");
uint runLength = *in++ * sizeof(word); uint runLength = *in++ * sizeof(word);
...@@ -298,7 +298,7 @@ void PackedInputStream::skip(size_t bytes) { ...@@ -298,7 +298,7 @@ void PackedInputStream::skip(size_t bytes) {
} }
} }
FAIL_CHECK("Can't get here."); FAIL_ASSERT("Can't get here.");
} }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
......
...@@ -96,7 +96,7 @@ public: ...@@ -96,7 +96,7 @@ public:
} }
size_t read(void* buffer, size_t minBytes, size_t maxBytes) override { size_t read(void* buffer, size_t minBytes, size_t maxBytes) override {
CHECK(maxBytes <= data.size() - readPos, "Overran end of stream."); ASSERT(maxBytes <= data.size() - readPos, "Overran end of stream.");
size_t amount = std::min(maxBytes, std::max(minBytes, preferredReadSize)); size_t amount = std::min(maxBytes, std::max(minBytes, preferredReadSize));
memcpy(buffer, data.data() + readPos, amount); memcpy(buffer, data.data() + readPos, amount);
readPos += amount; readPos += amount;
...@@ -104,7 +104,7 @@ public: ...@@ -104,7 +104,7 @@ public:
} }
void skip(size_t bytes) override { void skip(size_t bytes) override {
CHECK(bytes <= data.size() - readPos, "Overran end of stream."); ASSERT(bytes <= data.size() - readPos, "Overran end of stream.");
readPos += bytes; readPos += bytes;
} }
......
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
// implements snappy::Source --------------------------------------- // implements snappy::Source ---------------------------------------
size_t Available() const override { size_t Available() const override {
FAIL_CHECK("Snappy doesn't actually call this."); FAIL_ASSERT("Snappy doesn't actually call this.");
return 0; return 0;
} }
...@@ -121,7 +121,7 @@ void SnappyInputStream::refill() { ...@@ -121,7 +121,7 @@ void SnappyInputStream::refill() {
SnappyOutputStream::SnappyOutputStream( SnappyOutputStream::SnappyOutputStream(
OutputStream& inner, kj::ArrayPtr<byte> buffer, kj::ArrayPtr<byte> compressedBuffer) OutputStream& inner, kj::ArrayPtr<byte> buffer, kj::ArrayPtr<byte> compressedBuffer)
: inner(inner) { : inner(inner) {
DCHECK(SNAPPY_COMPRESSED_BUFFER_SIZE >= snappy::MaxCompressedLength(snappy::kBlockSize), DASSERT(SNAPPY_COMPRESSED_BUFFER_SIZE >= snappy::MaxCompressedLength(snappy::kBlockSize),
"snappy::MaxCompressedLength() changed?"); "snappy::MaxCompressedLength() changed?");
if (buffer.size() < SNAPPY_BUFFER_SIZE) { if (buffer.size() < SNAPPY_BUFFER_SIZE) {
...@@ -159,7 +159,7 @@ void SnappyOutputStream::flush() { ...@@ -159,7 +159,7 @@ void SnappyOutputStream::flush() {
snappy::UncheckedByteArraySink sink(reinterpret_cast<char*>(compressedBuffer.begin())); snappy::UncheckedByteArraySink sink(reinterpret_cast<char*>(compressedBuffer.begin()));
size_t n = snappy::Compress(&source, &sink); size_t n = snappy::Compress(&source, &sink);
CHECK(n <= compressedBuffer.size(), ASSERT(n <= compressedBuffer.size(),
"Critical security bug: Snappy compression overran its output buffer."); "Critical security bug: Snappy compression overran its output buffer.");
inner.write(compressedBuffer.begin(), n); inner.write(compressedBuffer.begin(), n);
......
...@@ -104,7 +104,7 @@ public: ...@@ -104,7 +104,7 @@ public:
~TestInputStream() {} ~TestInputStream() {}
size_t read(void* buffer, size_t minBytes, size_t maxBytes) override { size_t read(void* buffer, size_t minBytes, size_t maxBytes) override {
CHECK(maxBytes <= size_t(end - pos), "Overran end of stream."); ASSERT(maxBytes <= size_t(end - pos), "Overran end of stream.");
size_t amount = lazy ? minBytes : maxBytes; size_t amount = lazy ? minBytes : maxBytes;
memcpy(buffer, pos, amount); memcpy(buffer, pos, amount);
pos += amount; pos += amount;
......
...@@ -122,7 +122,7 @@ kj::Array<word> messageToFlatArray(kj::ArrayPtr<const kj::ArrayPtr<const word>> ...@@ -122,7 +122,7 @@ kj::Array<word> messageToFlatArray(kj::ArrayPtr<const kj::ArrayPtr<const word>>
dst += segment.size(); dst += segment.size();
} }
DCHECK(dst == result.end(), "Buffer overrun/underrun bug in code above."); DASSERT(dst == result.end(), "Buffer overrun/underrun bug in code above.");
return kj::mv(result); return kj::mv(result);
} }
......
...@@ -162,7 +162,7 @@ static void print(std::ostream& os, DynamicValue::Reader value, ...@@ -162,7 +162,7 @@ static void print(std::ostream& os, DynamicValue::Reader value,
break; break;
} }
case DynamicValue::INTERFACE: case DynamicValue::INTERFACE:
FAIL_RECOVERABLE_CHECK("Don't know how to print interfaces.") {} FAIL_RECOVERABLE_ASSERT("Don't know how to print interfaces.") {}
break; break;
case DynamicValue::OBJECT: case DynamicValue::OBJECT:
os << "(opaque object)"; os << "(opaque object)";
......
...@@ -33,11 +33,11 @@ namespace { ...@@ -33,11 +33,11 @@ namespace {
struct TestObject { struct TestObject {
TestObject() { TestObject() {
index = count; index = count;
CHECK(index != throwAt); ASSERT(index != throwAt);
++count; ++count;
} }
TestObject(const TestObject& other) { TestObject(const TestObject& other) {
CHECK(other.index != throwAt); ASSERT(other.index != throwAt);
index = -1; index = -1;
copiedCount++; copiedCount++;
} }
...@@ -47,7 +47,7 @@ struct TestObject { ...@@ -47,7 +47,7 @@ struct TestObject {
} else { } else {
--count; --count;
EXPECT_EQ(index, count); EXPECT_EQ(index, count);
CHECK(count != throwAt); ASSERT(count != throwAt);
} }
} }
......
...@@ -257,7 +257,7 @@ void FdOutputStream::write(const void* buffer, size_t size) { ...@@ -257,7 +257,7 @@ void FdOutputStream::write(const void* buffer, size_t size) {
while (size > 0) { while (size > 0) {
ssize_t n = SYSCALL(::write(fd, pos, size), fd); ssize_t n = SYSCALL(::write(fd, pos, size), fd);
CHECK(n > 0, "write() returned zero."); ASSERT(n > 0, "write() returned zero.");
pos += n; pos += n;
size -= n; size -= n;
} }
...@@ -281,7 +281,7 @@ void FdOutputStream::write(ArrayPtr<const ArrayPtr<const byte>> pieces) { ...@@ -281,7 +281,7 @@ void FdOutputStream::write(ArrayPtr<const ArrayPtr<const byte>> pieces) {
while (current < iov.end()) { while (current < iov.end()) {
ssize_t n = SYSCALL(::writev(fd, current, iov.end() - current), fd); ssize_t n = SYSCALL(::writev(fd, current, iov.end() - current), fd);
CHECK(n > 0, "writev() returned zero."); ASSERT(n > 0, "writev() returned zero.");
while (static_cast<size_t>(n) >= current->iov_len) { while (static_cast<size_t>(n) >= current->iov_len) {
n -= current->iov_len; n -= current->iov_len;
......
...@@ -101,24 +101,24 @@ TEST(Logging, Log) { ...@@ -101,24 +101,24 @@ TEST(Logging, Log) {
mockCallback.text); mockCallback.text);
mockCallback.text.clear(); mockCallback.text.clear();
CHECK(1 == 1); ASSERT(1 == 1);
EXPECT_THROW(CHECK(1 == 2), MockException); line = __LINE__; EXPECT_THROW(ASSERT(1 == 2), MockException); line = __LINE__;
EXPECT_EQ("fatal exception: " + fileLine(__FILE__, line) + ": bug in code: expected " EXPECT_EQ("fatal exception: " + fileLine(__FILE__, line) + ": bug in code: expected "
"1 == 2\n", mockCallback.text); "1 == 2\n", mockCallback.text);
mockCallback.text.clear(); mockCallback.text.clear();
RECOVERABLE_CHECK(1 == 1) { RECOVERABLE_ASSERT(1 == 1) {
ADD_FAILURE() << "Shouldn't call recovery code when check passes."; ADD_FAILURE() << "Shouldn't call recovery code when check passes.";
}; };
bool recovered = false; bool recovered = false;
RECOVERABLE_CHECK(1 == 2, "1 is not 2") { recovered = true; } line = __LINE__; RECOVERABLE_ASSERT(1 == 2, "1 is not 2") { recovered = true; } line = __LINE__;
EXPECT_EQ("recoverable exception: " + fileLine(__FILE__, line) + ": bug in code: expected " EXPECT_EQ("recoverable exception: " + fileLine(__FILE__, line) + ": bug in code: expected "
"1 == 2; 1 is not 2\n", mockCallback.text); "1 == 2; 1 is not 2\n", mockCallback.text);
EXPECT_TRUE(recovered); EXPECT_TRUE(recovered);
mockCallback.text.clear(); mockCallback.text.clear();
EXPECT_THROW(CHECK(1 == 2, i, "hi", str), MockException); line = __LINE__; EXPECT_THROW(ASSERT(1 == 2, i, "hi", str), MockException); line = __LINE__;
EXPECT_EQ("fatal exception: " + fileLine(__FILE__, line) + ": bug in code: expected " EXPECT_EQ("fatal exception: " + fileLine(__FILE__, line) + ": bug in code: expected "
"1 == 2; i = 123; hi; str = foo\n", mockCallback.text); "1 == 2; i = 123; hi; str = foo\n", mockCallback.text);
mockCallback.text.clear(); mockCallback.text.clear();
...@@ -128,7 +128,7 @@ TEST(Logging, Log) { ...@@ -128,7 +128,7 @@ TEST(Logging, Log) {
"1 == 2; i = 123; hi; str = foo\n", mockCallback.text); "1 == 2; i = 123; hi; str = foo\n", mockCallback.text);
mockCallback.text.clear(); mockCallback.text.clear();
EXPECT_THROW(CHECK(false, "foo"), MockException); line = __LINE__; EXPECT_THROW(ASSERT(false, "foo"), MockException); line = __LINE__;
EXPECT_EQ("fatal exception: " + fileLine(__FILE__, line) + ": bug in code: foo\n", EXPECT_EQ("fatal exception: " + fileLine(__FILE__, line) + ": bug in code: foo\n",
mockCallback.text); mockCallback.text);
mockCallback.text.clear(); mockCallback.text.clear();
...@@ -164,7 +164,7 @@ TEST(Logging, Context) { ...@@ -164,7 +164,7 @@ TEST(Logging, Context) {
{ {
CONTEXT("foo"); int cline = __LINE__; CONTEXT("foo"); int cline = __LINE__;
EXPECT_THROW(FAIL_CHECK("bar"), MockException); int line = __LINE__; EXPECT_THROW(FAIL_ASSERT("bar"), MockException); int line = __LINE__;
EXPECT_EQ("fatal exception: " + fileLine(__FILE__, cline) + ": context: foo\n" EXPECT_EQ("fatal exception: " + fileLine(__FILE__, cline) + ": context: foo\n"
+ fileLine(__FILE__, line) + ": bug in code: bar\n", + fileLine(__FILE__, line) + ": bug in code: bar\n",
...@@ -175,7 +175,7 @@ TEST(Logging, Context) { ...@@ -175,7 +175,7 @@ TEST(Logging, Context) {
int i = 123; int i = 123;
const char* str = "qux"; const char* str = "qux";
CONTEXT("baz", i, "corge", str); int cline2 = __LINE__; CONTEXT("baz", i, "corge", str); int cline2 = __LINE__;
EXPECT_THROW(FAIL_CHECK("bar"), MockException); line = __LINE__; EXPECT_THROW(FAIL_ASSERT("bar"), MockException); line = __LINE__;
EXPECT_EQ("fatal exception: " + fileLine(__FILE__, cline) + ": context: foo\n" EXPECT_EQ("fatal exception: " + fileLine(__FILE__, cline) + ": context: foo\n"
+ fileLine(__FILE__, cline2) + ": context: baz; i = 123; corge; str = qux\n" + fileLine(__FILE__, cline2) + ": context: baz; i = 123; corge; str = qux\n"
...@@ -186,7 +186,7 @@ TEST(Logging, Context) { ...@@ -186,7 +186,7 @@ TEST(Logging, Context) {
{ {
CONTEXT("grault"); int cline2 = __LINE__; CONTEXT("grault"); int cline2 = __LINE__;
EXPECT_THROW(FAIL_CHECK("bar"), MockException); line = __LINE__; EXPECT_THROW(FAIL_ASSERT("bar"), MockException); line = __LINE__;
EXPECT_EQ("fatal exception: " + fileLine(__FILE__, cline) + ": context: foo\n" EXPECT_EQ("fatal exception: " + fileLine(__FILE__, cline) + ": context: foo\n"
+ fileLine(__FILE__, cline2) + ": context: grault\n" + fileLine(__FILE__, cline2) + ": context: grault\n"
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
// This file declares convenient macros for debug logging and error handling. The macros make // This file declares convenient macros for debug logging and error handling. The macros make
// it excessively easy to extract useful context information from code. Example: // it excessively easy to extract useful context information from code. Example:
// //
// CHECK(a == b, a, b, "a and b must be the same."); // ASSERT(a == b, a, b, "a and b must be the same.");
// //
// On failure, this will throw an exception whose description looks like: // On failure, this will throw an exception whose description looks like:
// //
...@@ -39,19 +39,19 @@ ...@@ -39,19 +39,19 @@
// `FATAL`. If the severity is not higher than the global logging threshold, nothing will be // `FATAL`. If the severity is not higher than the global logging threshold, nothing will be
// written and in fact the log message won't even be evaluated. // written and in fact the log message won't even be evaluated.
// //
// * `CHECK(condition, ...)`: Throws an exception if `condition` is false, or aborts if exceptions // * `ASSERT(condition, ...)`: Throws an exception if `condition` is false, or aborts if exceptions
// are disabled. This macro should be used to check for bugs in the surrounding code and its // are disabled. This macro should be used to check for bugs in the surrounding code and its
// dependencies, but NOT to check for invalid input. // dependencies, but NOT to check for invalid input.
// //
// * `REQUIRE(condition, ...)`: Like `CHECK` but used to check preconditions -- e.g. to validate // * `REQUIRE(condition, ...)`: Like `ASSERT` but used to check preconditions -- e.g. to validate
// parameters passed from a caller. A failure indicates that the caller is buggy. // parameters passed from a caller. A failure indicates that the caller is buggy.
// //
// * `RECOVERABLE_CHECK(condition, ...) { ... }`: Like `CHECK` except that if exceptions are // * `RECOVERABLE_ASSERT(condition, ...) { ... }`: Like `ASSERT` except that if exceptions are
// disabled, instead of aborting, the following code block will be executed. This block should // disabled, instead of aborting, the following code block will be executed. This block should
// do whatever it can to fill in dummy values so that the code can continue executing, even if // do whatever it can to fill in dummy values so that the code can continue executing, even if
// this means the eventual output will be garbage. // this means the eventual output will be garbage.
// //
// * `RECOVERABLE_REQUIRE(condition, ...) { ... }`: Like `RECOVERABLE_CHECK` and `REQUIRE`. // * `RECOVERABLE_REQUIRE(condition, ...) { ... }`: Like `RECOVERABLE_ASSERT` and `REQUIRE`.
// //
// * `VALIDATE_INPUT(condition, ...) { ... }`: Like `RECOVERABLE_PRECOND` but used to validate // * `VALIDATE_INPUT(condition, ...) { ... }`: Like `RECOVERABLE_PRECOND` but used to validate
// input that may have come from the user or some other untrusted source. Recoverability is // input that may have come from the user or some other untrusted source. Recoverability is
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
// //
// int fd = SYSCALL(open(filename, O_RDONLY), filename); // int fd = SYSCALL(open(filename, O_RDONLY), filename);
// //
// * `RECOVERABLE_SYSCALL(code, ...) { ... }`: Like `RECOVERABLE_CHECK` and `SYSCALL`. Note that // * `RECOVERABLE_SYSCALL(code, ...) { ... }`: Like `RECOVERABLE_ASSERT` and `SYSCALL`. Note that
// unfortunately this macro cannot return a value since it implements control flow, but you can // unfortunately this macro cannot return a value since it implements control flow, but you can
// assign to a variable *inside* the parameter instead: // assign to a variable *inside* the parameter instead:
// //
...@@ -226,14 +226,14 @@ ArrayPtr<const char> KJ_STRINGIFY(Log::Severity severity); ...@@ -226,14 +226,14 @@ ArrayPtr<const char> KJ_STRINGIFY(Log::Severity severity);
::kj::Exception::Nature::nature, #cond, #__VA_ARGS__, ##__VA_ARGS__), false) {} \ ::kj::Exception::Nature::nature, #cond, #__VA_ARGS__, ##__VA_ARGS__), false) {} \
else else
#define CHECK(...) FAULT(LOCAL_BUG, __VA_ARGS__) #define ASSERT(...) FAULT(LOCAL_BUG, __VA_ARGS__)
#define RECOVERABLE_CHECK(...) RECOVERABLE_FAULT(LOCAL_BUG, __VA_ARGS__) #define RECOVERABLE_ASSERT(...) RECOVERABLE_FAULT(LOCAL_BUG, __VA_ARGS__)
#define REQUIRE(...) FAULT(PRECONDITION, __VA_ARGS__) #define REQUIRE(...) FAULT(PRECONDITION, __VA_ARGS__)
#define RECOVERABLE_REQUIRE(...) RECOVERABLE_FAULT(PRECONDITION, __VA_ARGS__) #define RECOVERABLE_REQUIRE(...) RECOVERABLE_FAULT(PRECONDITION, __VA_ARGS__)
#define VALIDATE_INPUT(...) RECOVERABLE_FAULT(INPUT, __VA_ARGS__) #define VALIDATE_INPUT(...) RECOVERABLE_FAULT(INPUT, __VA_ARGS__)
#define FAIL_CHECK(...) CHECK(false, ##__VA_ARGS__) #define FAIL_ASSERT(...) ASSERT(false, ##__VA_ARGS__)
#define FAIL_RECOVERABLE_CHECK(...) RECOVERABLE_CHECK(false, ##__VA_ARGS__) #define FAIL_RECOVERABLE_ASSERT(...) RECOVERABLE_ASSERT(false, ##__VA_ARGS__)
#define FAIL_REQUIRE(...) REQUIRE(false, ##__VA_ARGS__) #define FAIL_REQUIRE(...) REQUIRE(false, ##__VA_ARGS__)
#define FAIL_RECOVERABLE_REQUIRE(...) RECOVERABLE_REQUIRE(false, ##__VA_ARGS__) #define FAIL_RECOVERABLE_REQUIRE(...) RECOVERABLE_REQUIRE(false, ##__VA_ARGS__)
#define FAIL_VALIDATE_INPUT(...) VALIDATE_INPUT(false, ##__VA_ARGS__) #define FAIL_VALIDATE_INPUT(...) VALIDATE_INPUT(false, ##__VA_ARGS__)
...@@ -272,14 +272,14 @@ ArrayPtr<const char> KJ_STRINGIFY(Log::Severity severity); ...@@ -272,14 +272,14 @@ ArrayPtr<const char> KJ_STRINGIFY(Log::Severity severity);
#ifdef NDEBUG #ifdef NDEBUG
#define DLOG(...) do {} while (false) #define DLOG(...) do {} while (false)
#define DCHECK(...) do {} while (false) #define DASSERT(...) do {} while (false)
#define RECOVERABLE_DCHECK(...) do {} while (false) #define RECOVERABLE_DASSERT(...) do {} while (false)
#define DREQUIRE(...) do {} while (false) #define DREQUIRE(...) do {} while (false)
#define RECOVERABLE_DREQUIRE(...) do {} while (false) #define RECOVERABLE_DREQUIRE(...) do {} while (false)
#else #else
#define DLOG LOG #define DLOG LOG
#define DCHECK CHECK #define DASSERT ASSERT
#define RECOVERABLE_DCHECK RECOVERABLE_CHECK #define RECOVERABLE_DASSERT RECOVERABLE_ASSERT
#define DREQUIRE REQUIRE #define DREQUIRE REQUIRE
#define RECOVERABLE_DREQUIRE RECOVERABLE_REQUIRE #define RECOVERABLE_DREQUIRE RECOVERABLE_REQUIRE
#endif #endif
......
...@@ -232,7 +232,7 @@ char* DoubleToBuffer(double value, char* buffer) { ...@@ -232,7 +232,7 @@ char* DoubleToBuffer(double value, char* buffer) {
// The snprintf should never overflow because the buffer is significantly // The snprintf should never overflow because the buffer is significantly
// larger than the precision we asked for. // larger than the precision we asked for.
DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize); DASSERT(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize);
// We need to make parsed_value volatile in order to force the compiler to // We need to make parsed_value volatile in order to force the compiler to
// write it out to the stack. Otherwise, it may keep the value in a // write it out to the stack. Otherwise, it may keep the value in a
...@@ -246,7 +246,7 @@ char* DoubleToBuffer(double value, char* buffer) { ...@@ -246,7 +246,7 @@ char* DoubleToBuffer(double value, char* buffer) {
snprintf(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG+2, value); snprintf(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG+2, value);
// Should never overflow; see above. // Should never overflow; see above.
DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize); DASSERT(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize);
} }
DelocalizeRadix(buffer); DelocalizeRadix(buffer);
...@@ -288,7 +288,7 @@ char* FloatToBuffer(float value, char* buffer) { ...@@ -288,7 +288,7 @@ char* FloatToBuffer(float value, char* buffer) {
// The snprintf should never overflow because the buffer is significantly // The snprintf should never overflow because the buffer is significantly
// larger than the precision we asked for. // larger than the precision we asked for.
DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); DASSERT(snprintf_result > 0 && snprintf_result < kFloatToBufferSize);
float parsed_value; float parsed_value;
if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) { if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) {
...@@ -296,7 +296,7 @@ char* FloatToBuffer(float value, char* buffer) { ...@@ -296,7 +296,7 @@ char* FloatToBuffer(float value, char* buffer) {
snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG+2, value); snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG+2, value);
// Should never overflow; see above. // Should never overflow; see above.
DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); DASSERT(snprintf_result > 0 && snprintf_result < kFloatToBufferSize);
} }
DelocalizeRadix(buffer); DelocalizeRadix(buffer);
......
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