diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-05-01 08:33:07 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-05-01 10:50:11 +0200 |
commit | e6981b99ac5447f917287f5102a0a18b4972871e (patch) | |
tree | b5404b8b2447aeca8caab03f3606f2b066eba490 /connectivity | |
parent | 358b281a39c6599aa2054a9cf60aa6712e832150 (diff) |
WaE: C6011 Dereferencing NULL pointer warnings
Change-Id: Ic2c2e227a50994298377485e9e807cd9142cc386
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166949
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/commontools/TColumnsHelper.cxx | 4 | ||||
-rw-r--r-- | connectivity/source/parse/internalnode.cxx | 11 | ||||
-rw-r--r-- | connectivity/source/parse/sqliterator.cxx | 26 | ||||
-rw-r--r-- | connectivity/source/parse/sqlnode.cxx | 12 |
4 files changed, 24 insertions, 29 deletions
diff --git a/connectivity/source/commontools/TColumnsHelper.cxx b/connectivity/source/commontools/TColumnsHelper.cxx index aeb8b48a649a..b346b5a23236 100644 --- a/connectivity/source/commontools/TColumnsHelper.cxx +++ b/connectivity/source/commontools/TColumnsHelper.cxx @@ -64,10 +64,9 @@ OColumnsHelper::~OColumnsHelper() { } - sdbcx::ObjectType OColumnsHelper::createObject(const OUString& _rName) { - OSL_ENSURE(m_pTable,"NO Table set. Error!"); + assert(m_pTable && "NO Table set. Error!"); Reference<XConnection> xConnection = m_pTable->getConnection(); if ( !m_pImpl ) @@ -142,7 +141,6 @@ sdbcx::ObjectType OColumnsHelper::createObject(const OUString& _rName) return xRet; } - void OColumnsHelper::impl_refresh() { if ( m_pTable ) diff --git a/connectivity/source/parse/internalnode.cxx b/connectivity/source/parse/internalnode.cxx index 1906ad3d4625..9b7849345556 100644 --- a/connectivity/source/parse/internalnode.cxx +++ b/connectivity/source/parse/internalnode.cxx @@ -28,7 +28,7 @@ OSQLInternalNode::OSQLInternalNode(const char* pNewValue, sal_uInt32 nNodeID) : OSQLParseNode(pNewValue,eNodeType,nNodeID) { - OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized"); + assert(OSQLParser::s_pGarbageCollector && "Collector not initialized"); (*OSQLParser::s_pGarbageCollector)->push_back(this); } @@ -38,26 +38,23 @@ OSQLInternalNode::OSQLInternalNode(std::string_view NewValue, sal_uInt32 nNodeID) :OSQLParseNode(NewValue,eNodeType,nNodeID) { - OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized"); + assert(OSQLParser::s_pGarbageCollector && "Collector not initialized"); (*OSQLParser::s_pGarbageCollector)->push_back(this); } - OSQLInternalNode::OSQLInternalNode(const OUString &NewValue, SQLNodeType eNodeType, sal_uInt32 nNodeID) :OSQLParseNode(NewValue,eNodeType,nNodeID) { - OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized"); + assert(OSQLParser::s_pGarbageCollector && "Collector not initialized"); (*OSQLParser::s_pGarbageCollector)->push_back(this); } - OSQLInternalNode::~OSQLInternalNode() { // remove the node from the garbage list - - OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized"); + assert(OSQLParser::s_pGarbageCollector && "Collector not initialized"); (*OSQLParser::s_pGarbageCollector)->erase(this); } diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index f190d5dbfc97..3171507bcc67 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -610,7 +610,7 @@ void OSQLParseTreeIterator::getSelect_statement(OSQLTables& _rTables,const OSQLP } OSQLParseNode * pTableRefCommalist = pSelect->getChild(3)->getChild(0)->getChild(1); - OSL_ENSURE(pTableRefCommalist != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pTableRefCommalist != nullptr && "OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableRefCommalist,table_ref_commalist),"OSQLParseTreeIterator: error in parse tree!"); const OSQLParseNode* pTableName = nullptr; @@ -965,21 +965,21 @@ void OSQLParseTreeIterator::traverseByColumnNames(const OSQLParseNode* pSelectNo OSL_ENSURE(pSelectNode->count() >= 4,"OSQLParseTreeIterator: error in parse tree!"); OSQLParseNode * pTableExp = pSelectNode->getChild(3); - OSL_ENSURE(pTableExp != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pTableExp != nullptr && "OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator:table_exp error in parse tree!"); OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); sal_uInt32 nPos = ( _bOrder ? ORDER_BY_CHILD_POS : 2 ); OSQLParseNode * pOptByClause = pTableExp->getChild(nPos); - OSL_ENSURE(pOptByClause != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pOptByClause != nullptr && "OSQLParseTreeIterator: error in parse tree!"); if ( pOptByClause->count() == 0 ) return; OSL_ENSURE(pOptByClause->count() == 3,"OSQLParseTreeIterator: error in parse tree!"); OSQLParseNode * pOrderingSpecCommalist = pOptByClause->getChild(2); - OSL_ENSURE(pOrderingSpecCommalist != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pOrderingSpecCommalist != nullptr && "OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(!_bOrder || SQL_ISRULE(pOrderingSpecCommalist,ordering_spec_commalist),"OSQLParseTreeIterator:ordering_spec_commalist error in parse tree!"); OSL_ENSURE(pOrderingSpecCommalist->count() > 0,"OSQLParseTreeIterator: error in parse tree!"); @@ -989,7 +989,7 @@ void OSQLParseTreeIterator::traverseByColumnNames(const OSQLParseNode* pSelectNo for (sal_uInt32 i = 0; i < nCount; ++i) { OSQLParseNode* pColumnRef = pOrderingSpecCommalist->getChild(i); - OSL_ENSURE(pColumnRef != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pColumnRef != nullptr && "OSQLParseTreeIterator: error in parse tree!"); if ( _bOrder ) { OSL_ENSURE(SQL_ISRULE(pColumnRef,ordering_spec),"OSQLParseTreeIterator:ordering_spec error in parse tree!"); @@ -997,7 +997,7 @@ void OSQLParseTreeIterator::traverseByColumnNames(const OSQLParseNode* pSelectNo pColumnRef = pColumnRef->getChild(0); } - OSL_ENSURE(pColumnRef != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pColumnRef != nullptr && "OSQLParseTreeIterator: error in parse tree!"); aTableRange.clear(); sColumnName.clear(); if ( SQL_ISRULE(pColumnRef,column_ref) ) @@ -1123,7 +1123,7 @@ bool OSQLParseTreeIterator::traverseSelectionCriteria(const OSQLParseNode* pSele OSL_ENSURE(pSelectNode->count() >= 4,"OSQLParseTreeIterator: error in parse tree!"); OSQLParseNode * pTableExp = pSelectNode->getChild(3); - OSL_ENSURE(pTableExp != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pTableExp != nullptr && "OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); @@ -1221,8 +1221,8 @@ void OSQLParseTreeIterator::traverseSearchCondition(OSQLParseNode const * pSearc OSQLParseNode * pNum_value_exp = pPart2->getChild(nCurrentPos); OSQLParseNode * pOptEscape = pPart2->getChild(nCurrentPos+1); - OSL_ENSURE(pNum_value_exp != nullptr,"OSQLParseTreeIterator: error in parse tree!"); - OSL_ENSURE(pOptEscape != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pNum_value_exp != nullptr && "OSQLParseTreeIterator: error in parse tree!"); + assert(pOptEscape != nullptr && "OSQLParseTreeIterator: error in parse tree!"); if (pOptEscape->count() != 0) { @@ -1803,7 +1803,7 @@ const OSQLParseNode* OSQLParseTreeIterator::getWhereTree() const { OSL_ENSURE(m_pParseTree->count() >= 4,"ParseTreeIterator: error in parse tree!"); OSQLParseNode * pTableExp = m_pParseTree->getChild(3); - OSL_ENSURE(pTableExp != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pTableExp != nullptr && "OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); @@ -1844,7 +1844,7 @@ const OSQLParseNode* OSQLParseTreeIterator::getOrderTree() const OSQLParseNode * pOrderClause = nullptr; OSL_ENSURE(pParseTree->count() == 4, "OSQLParseTreeIterator::getOrderTree: expected a SELECT, and a SELECT must have exactly four children"); OSQLParseNode * pTableExp = pParseTree->getChild(3); - OSL_ENSURE(pTableExp != nullptr, "OSQLParseTreeIterator::getOrderTree: got NULL table_exp"); + assert(pTableExp != nullptr && "OSQLParseTreeIterator::getOrderTree: got NULL table_exp"); OSL_ENSURE(SQL_ISRULE(pTableExp, table_exp), "OSQLParseTreeIterator::getOrderTree: expected table_exp but got something else"); OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator::getOrderTree: table_exp doesn't have the expected number of children"); // tdf#141115 upgrade the above to an assert; @@ -1868,7 +1868,7 @@ const OSQLParseNode* OSQLParseTreeIterator::getGroupByTree() const OSQLParseNode * pGroupClause = nullptr; OSL_ENSURE(m_pParseTree->count() >= 4,"ParseTreeIterator: error in parse tree!"); OSQLParseNode * pTableExp = m_pParseTree->getChild(3); - OSL_ENSURE(pTableExp != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pTableExp != nullptr && "OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); @@ -1889,7 +1889,7 @@ const OSQLParseNode* OSQLParseTreeIterator::getHavingTree() const OSQLParseNode * pHavingClause = nullptr; OSL_ENSURE(m_pParseTree->count() >= 4,"ParseTreeIterator: error in parse tree!"); OSQLParseNode * pTableExp = m_pParseTree->getChild(3); - OSL_ENSURE(pTableExp != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pTableExp != nullptr && "OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index ad8f6c9edeff..823813b3f0e0 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -1676,10 +1676,9 @@ OSQLParseNode::~OSQLParseNode() { } - void OSQLParseNode::append(OSQLParseNode* pNewNode) { - OSL_ENSURE(pNewNode != nullptr, "OSQLParseNode: invalid NewSubTree"); + assert(pNewNode != nullptr && "OSQLParseNode: invalid NewSubTree"); OSL_ENSURE(pNewNode->getParent() == nullptr, "OSQLParseNode: Node is not an orphan"); OSL_ENSURE(std::none_of(m_aChildren.begin(), m_aChildren.end(), [&] (std::unique_ptr<OSQLParseNode> const & r) { return r.get() == pNewNode; }), @@ -2707,15 +2706,16 @@ OSQLParseNode::Rule OSQLParseNode::getKnownRuleID() const OUString OSQLParseNode::getTableRange(const OSQLParseNode* _pTableRef) { - OSL_ENSURE(_pTableRef && _pTableRef->count() > 1 && _pTableRef->getKnownRuleID() == OSQLParseNode::table_ref,"Invalid node give, only table ref is allowed!"); + assert(_pTableRef); + OSL_ENSURE(_pTableRef->count() > 1 && _pTableRef->getKnownRuleID() == OSQLParseNode::table_ref,"Invalid node give, only table ref is allowed!"); const sal_uInt32 nCount = _pTableRef->count(); OUString sTableRange; if ( nCount == 2 || (nCount == 3 && !_pTableRef->getChild(0)->isToken()) ) { const OSQLParseNode* pNode = _pTableRef->getChild(nCount - (nCount == 2 ? 1 : 2)); - OSL_ENSURE(pNode && (pNode->getKnownRuleID() == OSQLParseNode::table_primary_as_range_column - || pNode->getKnownRuleID() == OSQLParseNode::range_variable) - ,"SQL grammar changed!"); + assert(pNode); + OSL_ENSURE(pNode->getKnownRuleID() == OSQLParseNode::table_primary_as_range_column || + pNode->getKnownRuleID() == OSQLParseNode::range_variable, "SQL grammar changed!"); if ( !pNode->isLeaf() ) sTableRange = pNode->getChild(1)->getTokenValue(); } // if ( nCount == 2 || nCount == 3 ) |