From d1cde4457aed1f5cd58d1a11a593a4c0ad4c3460 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Fri, 15 Mar 2013 19:00:59 +0100 Subject: [PATCH] wrapped some assertions into TRI_ASSERT_DEBUG --- arangod/Ahuacatl/ahuacatl-access-optimiser.c | 181 ++++++++++--------- arangod/Ahuacatl/ahuacatl-context.c | 14 +- arangod/Ahuacatl/ahuacatl-conversions.c | 3 +- arangod/Ahuacatl/ahuacatl-node.c | 6 +- arangod/VocBase/document-collection.c | 5 +- arangod/VocBase/headers.c | 3 +- 6 files changed, 107 insertions(+), 105 deletions(-) diff --git a/arangod/Ahuacatl/ahuacatl-access-optimiser.c b/arangod/Ahuacatl/ahuacatl-access-optimiser.c index f3f62cb081..0fd35dec6e 100644 --- a/arangod/Ahuacatl/ahuacatl-access-optimiser.c +++ b/arangod/Ahuacatl/ahuacatl-access-optimiser.c @@ -236,8 +236,8 @@ static or_element_t* FindOrElement (const TRI_vector_pointer_t* const vector, const char* const name) { size_t i, n; - assert(vector); - assert(name); + TRI_ASSERT_DEBUG(vector != NULL); + TRI_ASSERT_DEBUG(name != NULL); n = vector->_length; for (i = 0; i < n; ++i) { @@ -245,7 +245,7 @@ static or_element_t* FindOrElement (const TRI_vector_pointer_t* const vector, current = (or_element_t*) TRI_AtVectorPointer(vector, i); - assert(current); + TRI_ASSERT_DEBUG(current != NULL); if (TRI_EqualString(name, current->_name)) { return current; @@ -275,8 +275,8 @@ static bool InsertOrs (TRI_aql_context_t* const context, fieldAccess = (TRI_aql_field_access_t*) TRI_AtVectorPointer(source, i); - assert(fieldAccess); - assert(fieldAccess->_fullName); + TRI_ASSERT_DEBUG(fieldAccess != NULL); + TRI_ASSERT_DEBUG(fieldAccess->_fullName != NULL); orElement = FindOrElement(dest, fieldAccess->_fullName); if (orElement == NULL) { @@ -336,8 +336,8 @@ static bool InsertOrs (TRI_aql_context_t* const context, static void SetNameLength (TRI_aql_field_access_t* const fieldAccess) { char* dotPosition; - assert(fieldAccess); - assert(fieldAccess->_fullName); + TRI_ASSERT_DEBUG(fieldAccess != NULL); + TRI_ASSERT_DEBUG(fieldAccess->_fullName != NULL); dotPosition = strchr(fieldAccess->_fullName, '.'); if (dotPosition == NULL) { @@ -354,7 +354,7 @@ static void SetNameLength (TRI_aql_field_access_t* const fieldAccess) { //////////////////////////////////////////////////////////////////////////////// static void FreeAccessMembers (TRI_aql_field_access_t* const fieldAccess) { - assert(fieldAccess); + TRI_ASSERT_DEBUG(fieldAccess != NULL); switch (fieldAccess->_type) { case TRI_AQL_ACCESS_EXACT: @@ -428,8 +428,8 @@ static TRI_aql_field_access_t* CreateFieldAccess (TRI_aql_context_t* const conte bool IsSameReference (const TRI_aql_field_access_t* const lhs, const TRI_aql_field_access_t* const rhs) { - assert(lhs->_type == TRI_AQL_ACCESS_REFERENCE); - assert(rhs->_type == TRI_AQL_ACCESS_REFERENCE); + TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_REFERENCE); + TRI_ASSERT_DEBUG(rhs->_type == TRI_AQL_ACCESS_REFERENCE); if (lhs->_value._reference._type == TRI_AQL_REFERENCE_VARIABLE && rhs->_value._reference._type == TRI_AQL_REFERENCE_VARIABLE) { @@ -469,7 +469,7 @@ static TRI_aql_field_access_t* MergeAndImpossible (TRI_aql_context_t* const cont TRI_aql_field_access_t* lhs, TRI_aql_field_access_t* rhs) { // impossible merged with anything just returns impossible - assert(lhs->_type == TRI_AQL_ACCESS_IMPOSSIBLE); + TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_IMPOSSIBLE); TRI_FreeAccessAql(rhs); return lhs; @@ -485,7 +485,7 @@ static TRI_aql_field_access_t* MergeAndAll (TRI_aql_context_t* const context, TRI_aql_field_access_t* lhs, TRI_aql_field_access_t* rhs) { // all merged with anything just returns the other side - assert(lhs->_type == TRI_AQL_ACCESS_ALL); + TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_ALL); TRI_FreeAccessAql(lhs); return rhs; @@ -501,7 +501,7 @@ static TRI_aql_field_access_t* MergeAndAll (TRI_aql_context_t* const context, static TRI_aql_field_access_t* MergeAndExact (TRI_aql_context_t* const context, TRI_aql_field_access_t* lhs, TRI_aql_field_access_t* rhs) { - assert(lhs->_type == TRI_AQL_ACCESS_EXACT); + TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_EXACT); if (rhs->_type == TRI_AQL_ACCESS_EXACT) { // check if values are identical @@ -623,7 +623,7 @@ static TRI_aql_field_access_t* MergeAndExact (TRI_aql_context_t* const context, static TRI_aql_field_access_t* MergeAndList (TRI_aql_context_t* const context, TRI_aql_field_access_t* lhs, TRI_aql_field_access_t* rhs) { - assert(lhs->_type == TRI_AQL_ACCESS_LIST); + TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_LIST); if (rhs->_type == TRI_AQL_ACCESS_LIST) { // make a list of both @@ -750,7 +750,7 @@ static TRI_aql_field_access_t* MergeAndList (TRI_aql_context_t* const context, static TRI_aql_field_access_t* MergeAndRangeSingle (TRI_aql_context_t* const context, TRI_aql_field_access_t* lhs, TRI_aql_field_access_t* rhs) { - assert(lhs->_type == TRI_AQL_ACCESS_RANGE_SINGLE); + TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_RANGE_SINGLE); if (rhs->_type == TRI_AQL_ACCESS_RANGE_SINGLE) { TRI_json_t* lhsValue; @@ -1095,7 +1095,7 @@ static TRI_aql_field_access_t* MergeAndRangeDouble (TRI_aql_context_t* const con TRI_aql_field_access_t* lhs, TRI_aql_field_access_t* rhs) { - assert(lhs->_type == TRI_AQL_ACCESS_RANGE_DOUBLE); + TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_RANGE_DOUBLE); if (rhs->_type == TRI_AQL_ACCESS_RANGE_DOUBLE) { int compareResult; @@ -1163,7 +1163,7 @@ static TRI_aql_field_access_t* MergeAndRangeDouble (TRI_aql_context_t* const con static TRI_aql_field_access_t* MergeAndReference (TRI_aql_context_t* const context, TRI_aql_field_access_t* lhs, TRI_aql_field_access_t* rhs) { - assert(lhs->_type == TRI_AQL_ACCESS_REFERENCE); + TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_REFERENCE); if (rhs->_type == TRI_AQL_ACCESS_REFERENCE) { TRI_aql_node_type_e lhsType = lhs->_value._reference._operator; @@ -1269,7 +1269,7 @@ static TRI_aql_field_access_t* MergeOrImpossible (TRI_aql_context_t* const conte TRI_aql_field_access_t* lhs, TRI_aql_field_access_t* rhs) { // impossible merged with anything just returns the other side - assert(lhs->_type == TRI_AQL_ACCESS_IMPOSSIBLE); + TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_IMPOSSIBLE); TRI_FreeAccessAql(lhs); return rhs; @@ -1285,7 +1285,7 @@ static TRI_aql_field_access_t* MergeOrAll (TRI_aql_context_t* const context, TRI_aql_field_access_t* lhs, TRI_aql_field_access_t* rhs) { // all merged with anything just returns all - assert(lhs->_type == TRI_AQL_ACCESS_ALL); + TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_ALL); TRI_FreeAccessAql(rhs); return lhs; @@ -1301,7 +1301,7 @@ static TRI_aql_field_access_t* MergeOrAll (TRI_aql_context_t* const context, static TRI_aql_field_access_t* MergeOrExact (TRI_aql_context_t* const context, TRI_aql_field_access_t* lhs, TRI_aql_field_access_t* rhs) { - assert(lhs->_type == TRI_AQL_ACCESS_EXACT); + TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_EXACT); if (rhs->_type == TRI_AQL_ACCESS_EXACT) { TRI_json_t* result; @@ -1448,7 +1448,7 @@ static TRI_aql_field_access_t* MergeOrExact (TRI_aql_context_t* const context, static TRI_aql_field_access_t* MergeOrList (TRI_aql_context_t* const context, TRI_aql_field_access_t* lhs, TRI_aql_field_access_t* rhs) { - assert(lhs->_type == TRI_AQL_ACCESS_LIST); + TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_LIST); if (rhs->_type == TRI_AQL_ACCESS_LIST) { // make a list of both @@ -1494,7 +1494,7 @@ static TRI_aql_field_access_t* MergeOrList (TRI_aql_context_t* const context, static TRI_aql_field_access_t* MergeOrRangeSingle (TRI_aql_context_t* const context, TRI_aql_field_access_t* lhs, TRI_aql_field_access_t* rhs) { - assert(lhs->_type == TRI_AQL_ACCESS_RANGE_SINGLE); + TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_RANGE_SINGLE); if (rhs->_type == TRI_AQL_ACCESS_RANGE_SINGLE) { TRI_aql_range_e lhsType; @@ -1594,7 +1594,7 @@ static TRI_aql_field_access_t* MergeOrRangeSingle (TRI_aql_context_t* const cont static TRI_aql_field_access_t* MergeOrRangeDouble (TRI_aql_context_t* const context, TRI_aql_field_access_t* lhs, TRI_aql_field_access_t* rhs) { - assert(lhs->_type == TRI_AQL_ACCESS_RANGE_DOUBLE); + TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_RANGE_DOUBLE); if (rhs->_type == TRI_AQL_ACCESS_RANGE_DOUBLE) { int compareResult; @@ -1665,7 +1665,7 @@ static TRI_aql_field_access_t* MergeOrRangeDouble (TRI_aql_context_t* const cont static TRI_aql_field_access_t* MergeOrReference (TRI_aql_context_t* const context, TRI_aql_field_access_t* lhs, TRI_aql_field_access_t* rhs) { - assert(lhs->_type == TRI_AQL_ACCESS_REFERENCE); + TRI_ASSERT_DEBUG(lhs->_type == TRI_AQL_ACCESS_REFERENCE); if (rhs->_type == TRI_AQL_ACCESS_REFERENCE) { TRI_aql_node_type_e lhsType = lhs->_value._reference._operator; @@ -1734,11 +1734,11 @@ static TRI_aql_field_access_t* MergeOrReference (TRI_aql_context_t* const contex static TRI_aql_field_access_t* MergeAttributeAccessAnd (TRI_aql_context_t* const context, TRI_aql_field_access_t* lhs, TRI_aql_field_access_t* rhs) { - assert(context); - assert(lhs); - assert(rhs); - assert(lhs->_fullName != NULL); - assert(rhs->_fullName != NULL); + TRI_ASSERT_DEBUG(context != NULL); + TRI_ASSERT_DEBUG(lhs != NULL); + TRI_ASSERT_DEBUG(rhs != NULL); + TRI_ASSERT_DEBUG(lhs->_fullName != NULL); + TRI_ASSERT_DEBUG(rhs->_fullName != NULL); if (lhs->_type > rhs->_type) { // swap operands so they are always sorted @@ -1747,7 +1747,7 @@ static TRI_aql_field_access_t* MergeAttributeAccessAnd (TRI_aql_context_t* const rhs = tmp; } - assert(lhs->_type <= rhs->_type); + TRI_ASSERT_DEBUG(lhs->_type <= rhs->_type); switch (lhs->_type) { case TRI_AQL_ACCESS_IMPOSSIBLE: @@ -1777,11 +1777,11 @@ static TRI_aql_field_access_t* MergeAttributeAccessAnd (TRI_aql_context_t* const static TRI_aql_field_access_t* MergeAttributeAccessOr (TRI_aql_context_t* const context, TRI_aql_field_access_t* lhs, TRI_aql_field_access_t* rhs) { - assert(context); - assert(lhs); - assert(rhs); - assert(lhs->_fullName != NULL); - assert(rhs->_fullName != NULL); + TRI_ASSERT_DEBUG(context != NULL); + TRI_ASSERT_DEBUG(lhs != NULL); + TRI_ASSERT_DEBUG(rhs != NULL); + TRI_ASSERT_DEBUG(lhs->_fullName != NULL); + TRI_ASSERT_DEBUG(rhs->_fullName != NULL); if (lhs->_type > rhs->_type) { // swap operands so they are always sorted @@ -1790,7 +1790,7 @@ static TRI_aql_field_access_t* MergeAttributeAccessOr (TRI_aql_context_t* const rhs = tmp; } - assert(lhs->_type <= rhs->_type); + TRI_ASSERT_DEBUG(lhs->_type <= rhs->_type); switch (lhs->_type) { case TRI_AQL_ACCESS_IMPOSSIBLE: @@ -1829,10 +1829,11 @@ static TRI_aql_field_access_t* MergeAttributeAccessOr (TRI_aql_context_t* const static TRI_vector_pointer_t* CreateEmptyVector (TRI_aql_context_t* const context) { TRI_vector_pointer_t* result; - assert(context); + TRI_ASSERT_DEBUG(context != NULL); result = (TRI_vector_pointer_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_vector_pointer_t), false); - if (!result) { + + if (result == NULL) { // OOM TRI_SetErrorContextAql(context, TRI_ERROR_OUT_OF_MEMORY, NULL); return NULL; @@ -1851,13 +1852,14 @@ static TRI_vector_pointer_t* Vectorize (TRI_aql_context_t* const context, TRI_aql_field_access_t* fieldAccess) { TRI_vector_pointer_t* vector; - assert(context); - if (!fieldAccess) { + TRI_ASSERT_DEBUG(context != NULL); + + if (fieldAccess == NULL) { return NULL; } vector = CreateEmptyVector(context); - if (!vector) { + if (vector == NULL) { return NULL; } @@ -1876,7 +1878,7 @@ static TRI_vector_pointer_t* MakeAllVector (TRI_aql_context_t* const context, TRI_vector_pointer_t* const fieldAccesses) { size_t i, n; - if (!fieldAccesses) { + if (fieldAccesses == NULL) { return NULL; } @@ -1885,8 +1887,8 @@ static TRI_vector_pointer_t* MakeAllVector (TRI_aql_context_t* const context, // turn all field access values into an all items access TRI_aql_field_access_t* fieldAccess = (TRI_aql_field_access_t*) TRI_AtVectorPointer(fieldAccesses, i); - assert(fieldAccess); - assert(fieldAccess->_fullName); + TRI_ASSERT_DEBUG(fieldAccess != NULL); + TRI_ASSERT_DEBUG(fieldAccess->_fullName != NULL); // modify the element in place FreeAccessMembers(fieldAccess); @@ -1908,8 +1910,8 @@ static void MergeVector (TRI_aql_context_t* const context, const TRI_vector_pointer_t* const source) { size_t i, n; - assert(result); - assert(source); + TRI_ASSERT_DEBUG(result != NULL); + TRI_ASSERT_DEBUG(source != NULL); n = source->_length; for (i = 0; i < n; ++i) { @@ -1917,8 +1919,8 @@ static void MergeVector (TRI_aql_context_t* const context, size_t j, len; bool found = false; - assert(fieldAccess); - assert(fieldAccess->_fullName); + TRI_ASSERT_DEBUG(fieldAccess != NULL); + TRI_ASSERT_DEBUG(fieldAccess->_fullName != NULL); // check if element is in result vector already len = result->_length; @@ -1961,20 +1963,20 @@ static void InsertVector (TRI_aql_context_t* const context, const TRI_vector_pointer_t* const source) { size_t i, n; - assert(result); - assert(source); + TRI_ASSERT_DEBUG(result != NULL); + TRI_ASSERT_DEBUG(source != NULL); n = source->_length; for (i = 0; i < n; ++i) { TRI_aql_field_access_t* fieldAccess = (TRI_aql_field_access_t*) TRI_AtVectorPointer(source, i); TRI_aql_field_access_t* copy; - - assert(fieldAccess); - assert(fieldAccess->_fullName); + + TRI_ASSERT_DEBUG(fieldAccess != NULL); + TRI_ASSERT_DEBUG(fieldAccess->_fullName != NULL); copy = TRI_CloneAccessAql(context, fieldAccess); - if (! copy) { + if (copy == NULL) { // OOM TRI_SetErrorContextAql(context, TRI_ERROR_OUT_OF_MEMORY, NULL); return; @@ -1996,8 +1998,8 @@ static TRI_vector_pointer_t* MergeVectors (TRI_aql_context_t* const context, TRI_vector_pointer_t* result; TRI_vector_pointer_t* orElements; - assert(context); - assert(mergeType == TRI_AQL_NODE_OPERATOR_BINARY_AND || mergeType == TRI_AQL_NODE_OPERATOR_BINARY_OR); + TRI_ASSERT_DEBUG(context != NULL); + TRI_ASSERT_DEBUG(mergeType == TRI_AQL_NODE_OPERATOR_BINARY_AND || mergeType == TRI_AQL_NODE_OPERATOR_BINARY_OR); // first check if we can get away without copying/merging the vectors if (inheritedRestrictions == NULL) { @@ -2015,7 +2017,7 @@ static TRI_vector_pointer_t* MergeVectors (TRI_aql_context_t* const context, } result = CreateEmptyVector(context); - if (! result) { + if (result == NULL) { // free memory if (lhs) { TRI_FreeVectorPointer(TRI_UNKNOWN_MEM_ZONE, lhs); @@ -2082,7 +2084,7 @@ static TRI_vector_pointer_t* MergeVectors (TRI_aql_context_t* const context, or_element_t* orElement; fieldAccess = (TRI_aql_field_access_t*) TRI_AtVectorPointer(result, i); - assert(fieldAccess); + TRI_ASSERT_DEBUG(fieldAccess != NULL); if (fieldAccess->_type == TRI_AQL_ACCESS_ALL) { continue; @@ -2101,7 +2103,7 @@ static TRI_vector_pointer_t* MergeVectors (TRI_aql_context_t* const context, or_element_t* orElement; orElement = (or_element_t*) TRI_AtVectorPointer(orElements, i); - assert(orElement); + TRI_ASSERT_DEBUG(orElement != NULL); // free members TRI_FreeString(TRI_UNKNOWN_MEM_ZONE, orElement->_name); @@ -2139,10 +2141,10 @@ static TRI_aql_field_access_t* CreateAccessForNode (TRI_aql_context_t* const con TRI_aql_field_access_t* fieldAccess; TRI_json_t* value; - assert(context); - assert(field); - assert(field->_name._buffer); - assert(node); + TRI_ASSERT_DEBUG(context != NULL); + TRI_ASSERT_DEBUG(field != NULL); + TRI_ASSERT_DEBUG(field->_name._buffer != NULL); + TRI_ASSERT_DEBUG(node != NULL); fieldAccess = (TRI_aql_field_access_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_aql_field_access_t), false); if (fieldAccess == NULL) { @@ -2225,7 +2227,7 @@ static TRI_aql_field_access_t* CreateAccessForNode (TRI_aql_context_t* const con else if (operator == TRI_AQL_NODE_OPERATOR_BINARY_IN) { TRI_json_t* list; - assert(value->_type == TRI_JSON_LIST); + TRI_ASSERT_DEBUG(value->_type == TRI_JSON_LIST); // create a list access fieldAccess->_type = TRI_AQL_ACCESS_LIST; @@ -2264,8 +2266,8 @@ static TRI_aql_field_access_t* GetAttributeAccess (TRI_aql_context_t* const cont const TRI_aql_node_t* const node) { TRI_aql_field_access_t* fieldAccess; - assert(context); - assert(node); + TRI_ASSERT_DEBUG(context != NULL); + TRI_ASSERT_DEBUG(node != NULL); if (field == NULL || ! field->_name._buffer) { // this is ok if the node type is not supported @@ -2289,8 +2291,8 @@ static TRI_aql_field_access_t* GetAttributeAccess (TRI_aql_context_t* const cont static TRI_aql_attribute_name_t* GetAttributeName (TRI_aql_context_t* const context, const TRI_aql_node_t* const node) { - assert(context); - assert(node); + TRI_ASSERT_DEBUG(context != NULL); + TRI_ASSERT_DEBUG(node != NULL); if (node->_type == TRI_AQL_NODE_ATTRIBUTE_ACCESS) { TRI_aql_attribute_name_t* field = GetAttributeName(context, TRI_AQL_NODE_MEMBER(node, 0)); @@ -2360,13 +2362,13 @@ static TRI_vector_pointer_t* ProcessNode (TRI_aql_context_t* const context, TRI_aql_node_t* node, bool* changed, const TRI_vector_pointer_t* const inheritedRestrictions) { - assert(context); - assert(node); + TRI_ASSERT_DEBUG(context != NULL); + TRI_ASSERT_DEBUG(node != NULL); if (node->_type == TRI_AQL_NODE_OPERATOR_UNARY_NOT) { TRI_aql_node_t* lhs = TRI_AQL_NODE_MEMBER(node, 0); - assert(lhs); + TRI_ASSERT_DEBUG(lhs != NULL); // can ignore inherited restrictions here return MakeAllVector(context, ProcessNode(context, lhs, changed, NULL)); @@ -2378,8 +2380,8 @@ static TRI_vector_pointer_t* ProcessNode (TRI_aql_context_t* const context, TRI_aql_node_t* rhs = TRI_AQL_NODE_MEMBER(node, 1); TRI_vector_pointer_t* result; - assert(lhs); - assert(rhs); + TRI_ASSERT_DEBUG(lhs != NULL); + TRI_ASSERT_DEBUG(rhs != NULL); // recurse into next level result = MergeVectors(context, @@ -2446,7 +2448,8 @@ static TRI_vector_pointer_t* ProcessNode (TRI_aql_context_t* const context, node1 = rhs; node2 = lhs; operator = TRI_ReverseOperatorRelationalAql(node->_type); - assert(operator != TRI_AQL_NODE_NOP); + + TRI_ASSERT_DEBUG(operator != TRI_AQL_NODE_NOP); if (lhs->_type == TRI_AQL_NODE_REFERENCE || lhs->_type == TRI_AQL_NODE_ATTRIBUTE_ACCESS || lhs->_type == TRI_AQL_NODE_FCALL) { // expression of type reference|attribute access|fcall operator reference|attribute access|fcall @@ -2564,7 +2567,7 @@ TRI_aql_field_access_t* TRI_CreateImpossibleAccessAql (TRI_aql_context_t* const bool TRI_ContainsImpossibleAql (const TRI_vector_pointer_t* const fieldAccesses) { size_t i, n; - if (!fieldAccesses) { + if (fieldAccesses == NULL) { return false; } @@ -2572,7 +2575,7 @@ bool TRI_ContainsImpossibleAql (const TRI_vector_pointer_t* const fieldAccesses) for (i = 0; i < n; ++i) { TRI_aql_field_access_t* fieldAccess = (TRI_aql_field_access_t*) TRI_AtVectorPointer(fieldAccesses, i); - assert(fieldAccess); + TRI_ASSERT_DEBUG(fieldAccess != NULL); if (fieldAccess->_type == TRI_AQL_ACCESS_IMPOSSIBLE) { // impossible range found @@ -2592,12 +2595,12 @@ TRI_vector_pointer_t* TRI_CloneAccessesAql (TRI_aql_context_t* const context, const TRI_vector_pointer_t* const source) { TRI_vector_pointer_t* result; - if (!source) { + if (source == NULL) { return NULL; } result = CreateEmptyVector(context); - if (!result) { + if (result == NULL) { return NULL; } @@ -2611,7 +2614,7 @@ TRI_vector_pointer_t* TRI_CloneAccessesAql (TRI_aql_context_t* const context, //////////////////////////////////////////////////////////////////////////////// void TRI_FreeAccessAql (TRI_aql_field_access_t* const fieldAccess) { - assert(fieldAccess); + TRI_ASSERT_DEBUG(fieldAccess != NULL); FreeAccessMembers(fieldAccess); TRI_Free(TRI_UNKNOWN_MEM_ZONE, fieldAccess->_fullName); @@ -2626,8 +2629,8 @@ TRI_aql_field_access_t* TRI_CloneAccessAql (TRI_aql_context_t* const context, TRI_aql_field_access_t* const source) { TRI_aql_field_access_t* fieldAccess; - assert(source); - assert(source->_fullName); + TRI_ASSERT_DEBUG(source != NULL); + TRI_ASSERT_DEBUG(source->_fullName != NULL); fieldAccess = CreateFieldAccess(context, source->_type, source->_fullName); if (fieldAccess == NULL) { @@ -2697,12 +2700,12 @@ TRI_aql_field_access_t* TRI_CloneAccessAql (TRI_aql_context_t* const context, int TRI_PickAccessAql (const TRI_aql_field_access_t* const lhs, const TRI_aql_field_access_t* const rhs) { - if (!lhs) { + if (lhs == NULL) { // lhs does not exist, simply return other side return 1; } - if (!rhs) { + if (rhs == NULL) { // rhs does not exist, simply return other side return -1; } @@ -2749,7 +2752,7 @@ void TRI_FreeAccessesAql (TRI_vector_pointer_t* const fieldAccesses) { n = fieldAccesses->_length; for (i = 0; i < n; ++i) { TRI_aql_field_access_t* fieldAccess = (TRI_aql_field_access_t*) TRI_AtVectorPointer(fieldAccesses, i); - + TRI_FreeAccessAql(fieldAccess); } @@ -2768,9 +2771,9 @@ TRI_vector_pointer_t* TRI_AddAccessAql (TRI_aql_context_t* const context, size_t i, n; bool found; - assert(context); - assert(candidate); - assert(candidate->_fullName); + TRI_ASSERT_DEBUG(context != NULL); + TRI_ASSERT_DEBUG(candidate != NULL); + TRI_ASSERT_DEBUG(candidate->_fullName != NULL); if (previous != NULL) { // use existing vector if already available @@ -2785,7 +2788,7 @@ TRI_vector_pointer_t* TRI_AddAccessAql (TRI_aql_context_t* const context, } } - assert(accesses); + TRI_ASSERT_DEBUG(accesses != NULL); found = false; n = accesses->_length; @@ -2806,7 +2809,7 @@ TRI_vector_pointer_t* TRI_AddAccessAql (TRI_aql_context_t* const context, TRI_aql_field_access_t* copy; // free existing field access - assert(existing); + TRI_ASSERT_DEBUG(existing != NULL); TRI_FreeAccessAql(existing); copy = TRI_CloneAccessAql(context, candidate); if (copy == NULL) { diff --git a/arangod/Ahuacatl/ahuacatl-context.c b/arangod/Ahuacatl/ahuacatl-context.c index fdfd965f7e..0b8818729f 100644 --- a/arangod/Ahuacatl/ahuacatl-context.c +++ b/arangod/Ahuacatl/ahuacatl-context.c @@ -167,8 +167,8 @@ TRI_aql_context_t* TRI_CreateContextAql (TRI_vocbase_t* vocbase, const char* const query) { TRI_aql_context_t* context; - assert(vocbase); - assert(query); + TRI_ASSERT_DEBUG(vocbase != NULL); + TRI_ASSERT_DEBUG(query != NULL); LOG_TRACE("creating context"); @@ -248,7 +248,7 @@ TRI_aql_context_t* TRI_CreateContextAql (TRI_vocbase_t* vocbase, //////////////////////////////////////////////////////////////////////////////// void TRI_FreeContextAql (TRI_aql_context_t* const context) { - assert(context); + TRI_ASSERT_DEBUG(context != NULL); LOG_TRACE("freeing context"); @@ -388,8 +388,8 @@ bool TRI_SetupCollectionsContextAql (TRI_aql_context_t* const context) { bool TRI_RegisterNodeContextAql (TRI_aql_context_t* const context, void* const node) { - assert(context); - assert(node); + TRI_ASSERT_DEBUG(context != NULL); + TRI_ASSERT_DEBUG(node != NULL); TRI_PushBackVectorPointer(&context->_memory._nodes, node); @@ -436,8 +436,8 @@ void TRI_SetErrorContextAql (TRI_aql_context_t* const context, const int code, const char* const data) { - assert(context); - assert(code > 0); + TRI_ASSERT_DEBUG(context != NULL); + TRI_ASSERT_DEBUG(code > 0); if (context->_error._code == 0) { // do not overwrite previous error diff --git a/arangod/Ahuacatl/ahuacatl-conversions.c b/arangod/Ahuacatl/ahuacatl-conversions.c index 921b048a26..7cd86703e5 100644 --- a/arangod/Ahuacatl/ahuacatl-conversions.c +++ b/arangod/Ahuacatl/ahuacatl-conversions.c @@ -253,9 +253,8 @@ TRI_aql_node_t* TRI_JsonNodeAql (TRI_aql_context_t* const context, TRI_aql_node_t* member; subJson = (TRI_json_t*) TRI_AtVector(&json->_value._objects, i); - assert(subJson); - member = TRI_JsonNodeAql(context, subJson); + if (member) { TRI_PushBackVectorPointer(&node->_members, (void*) member); } diff --git a/arangod/Ahuacatl/ahuacatl-node.c b/arangod/Ahuacatl/ahuacatl-node.c index 146634870e..bdafcf0ab1 100644 --- a/arangod/Ahuacatl/ahuacatl-node.c +++ b/arangod/Ahuacatl/ahuacatl-node.c @@ -202,7 +202,7 @@ bool TRI_IsListNodeAql (const TRI_aql_node_t* const node) { //////////////////////////////////////////////////////////////////////////////// bool TRI_IsConstantValueNodeAql (const TRI_aql_node_t* const node) { - assert(node); + TRI_ASSERT_DEBUG(node != NULL); if (node->_type != TRI_AQL_NODE_VALUE && node->_type != TRI_AQL_NODE_LIST && @@ -246,7 +246,7 @@ bool TRI_IsConstantValueNodeAql (const TRI_aql_node_t* const node) { //////////////////////////////////////////////////////////////////////////////// bool TRI_IsNumericValueNodeAql (const TRI_aql_node_t* const node) { - assert(node); + TRI_ASSERT_DEBUG(node != NULL); if (node->_type != TRI_AQL_NODE_VALUE) { return false; @@ -261,7 +261,7 @@ bool TRI_IsNumericValueNodeAql (const TRI_aql_node_t* const node) { //////////////////////////////////////////////////////////////////////////////// bool TRI_IsBooleanValueNodeAql (const TRI_aql_node_t* const node) { - assert(node); + TRI_ASSERT_DEBUG(node != NULL); return (node->_type == TRI_AQL_NODE_VALUE && node->_value._type == TRI_AQL_TYPE_BOOL); } diff --git a/arangod/VocBase/document-collection.c b/arangod/VocBase/document-collection.c index 6e842ea61e..421cd1a541 100644 --- a/arangod/VocBase/document-collection.c +++ b/arangod/VocBase/document-collection.c @@ -2127,7 +2127,7 @@ TRI_document_collection_t* TRI_CreateDocumentCollection (TRI_vocbase_t* vocbase, return NULL; } - assert(keyGenerator != NULL); + TRI_ASSERT_DEBUG(keyGenerator != NULL); // first create the document collection @@ -2332,11 +2332,10 @@ TRI_document_collection_t* TRI_OpenDocumentCollection (TRI_vocbase_t* vocbase, c return NULL; } - assert(keyGenerator != NULL); + TRI_ASSERT_DEBUG(keyGenerator != NULL); document->base._keyGenerator = keyGenerator; - assert(shaper); shapeCollection = TRI_CollectionVocShaper(shaper); if (shapeCollection != NULL) { shapeCollection->base._info._waitForSync = (vocbase->_forceSyncShapes || collection->_info._waitForSync); diff --git a/arangod/VocBase/headers.c b/arangod/VocBase/headers.c index a95b9864f0..d0b6f4b5b7 100644 --- a/arangod/VocBase/headers.c +++ b/arangod/VocBase/headers.c @@ -94,7 +94,8 @@ static size_t GetBlockSize (const size_t blockNumber) { //////////////////////////////////////////////////////////////////////////////// static void ClearSimpleHeaders (TRI_doc_mptr_t* header, size_t headerSize) { - assert(header); + TRI_ASSERT_DEBUG(header); + memset(header, 0, headerSize); }