From a551290fc46d5f91b89615700c88b863a403bc7a Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 8 May 2024 09:39:25 +0100 Subject: WaE: C6011 Dereferencing NULL pointer warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia64d863baa72a2d32a8bee40968af4f6aacd88bb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167332 Reviewed-by: Caolán McNamara Tested-by: Jenkins --- dbaccess/source/core/api/column.cxx | 2 +- dbaccess/source/core/misc/dsntypes.cxx | 2 +- dbaccess/source/ui/browser/unodatbr.cxx | 6 +++--- dbaccess/source/ui/dlg/DbAdminImpl.cxx | 20 ++++++++++---------- dbaccess/source/ui/dlg/sqlmessage.cxx | 2 +- .../source/ui/querydesign/QTableConnectionData.cxx | 4 ++-- dbaccess/source/ui/querydesign/QTableWindow.cxx | 2 +- dbaccess/source/ui/querydesign/QueryDesignView.cxx | 2 +- dbaccess/source/ui/querydesign/QueryTableView.cxx | 4 ++-- dbaccess/source/ui/querydesign/TableWindowTitle.cxx | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/core/api/column.cxx b/dbaccess/source/core/api/column.cxx index 58a8c1649cea..15378e22fd82 100644 --- a/dbaccess/source/core/api/column.cxx +++ b/dbaccess/source/core/api/column.cxx @@ -186,7 +186,7 @@ void OColumns::append( const OUString& _rName, OColumn* _pColumn ) { MutexGuard aGuard(m_rMutex); - OSL_ENSURE( _pColumn, "OColumns::append: invalid column!" ); + assert(_pColumn && "OColumns::append: invalid column!"); OSL_ENSURE( !m_pElements->exists( _rName ),"OColumns::append: Column already exists"); _pColumn->m_sName = _rName; diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx index 2162c07240cb..0a25d603d4f1 100644 --- a/dbaccess/source/core/misc/dsntypes.cxx +++ b/dbaccess/source/core/misc/dsntypes.cxx @@ -509,7 +509,7 @@ ODsnTypeCollection::TypeIterator::TypeIterator(const ODsnTypeCollection* _pConta :m_pContainer(_pContainer) ,m_nPosition(_nInitialPos) { - OSL_ENSURE(m_pContainer, "ODsnTypeCollection::TypeIterator::TypeIterator : invalid container!"); + assert(m_pContainer && "ODsnTypeCollection::TypeIterator::TypeIterator : invalid container!"); #if OSL_DEBUG_LEVEL > 0 ++const_cast(m_pContainer)->m_nLivingIterators; #endif diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index bb226afc669f..e8c6f007719e 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -1055,7 +1055,7 @@ OUString SbaTableQueryBrowser::getDataSourceAccessor(const weld::TreeIter& rData { weld::TreeView& rTreeView = m_pTreeView->GetWidget(); DBTreeListUserData* pData = weld::fromId(rTreeView.get_id(rDataSourceEntry)); - OSL_ENSURE( pData, "SbaTableQueryBrowser::getDataSourceAccessor: invalid entry data!" ); + assert(pData && "SbaTableQueryBrowser::getDataSourceAccessor: invalid entry data!"); OSL_ENSURE( pData->eType == etDatasource, "SbaTableQueryBrowser::getDataSourceAccessor: entry does not denote a data source!" ); return !pData->sAccessor.isEmpty() ? pData->sAccessor : GetEntryText(rDataSourceEntry); } @@ -2253,7 +2253,7 @@ bool SbaTableQueryBrowser::ensureEntryObject(const weld::TreeIter& rEntry) // the user data of the entry weld::TreeView& rTreeView = m_pTreeView->GetWidget(); DBTreeListUserData* pEntryData = weld::fromId(rTreeView.get_id(rEntry)); - OSL_ENSURE(pEntryData,"ensureEntryObject: user data should already be set!"); + assert(pEntryData && "ensureEntryObject: user data should already be set!"); std::unique_ptr xDataSourceEntry = m_pTreeView->GetRootLevelParent(&rEntry); @@ -2759,7 +2759,7 @@ void SAL_CALL SbaTableQueryBrowser::elementInserted(const ContainerEvent& rEvent // insert the new entry into the tree DBTreeListUserData* pContainerData = weld::fromId(rTreeView.get_id(*xEntry)); - OSL_ENSURE(pContainerData, "elementInserted: There must be user data for this type!"); + assert(pContainerData && "elementInserted: There must be user data for this type!"); DBTreeListUserData* pNewData = new DBTreeListUserData; bool bIsTable = etTableContainer == pContainerData->eType; diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx index 90ca68f2d3d5..d1cbaa964c0a 100644 --- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx +++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx @@ -431,9 +431,9 @@ Reference< XPropertySet > const & ODbDataSourceAdministrationHelper::getCurrentD OUString ODbDataSourceAdministrationHelper::getDatasourceType( const SfxItemSet& _rSet ) { const SfxStringItem* pConnectURL = _rSet.GetItem(DSID_CONNECTURL); - OSL_ENSURE( pConnectURL , "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!" ); + assert(pConnectURL && "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!"); const DbuTypeCollectionItem* pTypeCollection = _rSet.GetItem(DSID_TYPECOLLECTION); - OSL_ENSURE(pTypeCollection, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!"); + assert(pTypeCollection && "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!"); ::dbaccess::ODsnTypeCollection* pCollection = pTypeCollection->getCollection(); return pCollection->getType(pConnectURL->GetValue()); } @@ -452,10 +452,10 @@ OUString ODbDataSourceAdministrationHelper::getConnectionURL() const const SfxStringItem* pUrlItem = m_pItemSetHelper->getOutputSet()->GetItem(DSID_CONNECTURL); const DbuTypeCollectionItem* pTypeCollection = m_pItemSetHelper->getOutputSet()->GetItem(DSID_TYPECOLLECTION); - OSL_ENSURE(pUrlItem,"Connection URL is NULL. -> GPF!"); - OSL_ENSURE(pTypeCollection, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!"); + assert(pUrlItem && "Connection URL is NULL. -> GPF!"); + assert(pTypeCollection && "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!"); ::dbaccess::ODsnTypeCollection* pCollection = pTypeCollection->getCollection(); - OSL_ENSURE(pCollection, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid type collection!"); + assert(pCollection && "ODbDataSourceAdministrationHelper::getDatasourceType: invalid type collection!"); switch( pCollection->determineType(eType) ) { @@ -961,7 +961,7 @@ void ODbDataSourceAdministrationHelper::implTranslateProperty( SfxItemSet& _rSet TypeDescription aTD(_rValue.getValueType()); typelib_IndirectTypeDescription* pSequenceTD = reinterpret_cast< typelib_IndirectTypeDescription* >(aTD.get()); - OSL_ENSURE(pSequenceTD && pSequenceTD->pType, "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid sequence type!"); + assert(pSequenceTD && pSequenceTD->pType && "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid sequence type!"); Type aElementType(pSequenceTD->pType); switch (aElementType.getTypeClass()) @@ -996,7 +996,7 @@ void ODbDataSourceAdministrationHelper::implTranslateProperty( SfxItemSet& _rSet OUString ODbDataSourceAdministrationHelper::getDocumentUrl(SfxItemSet const & _rDest) { const SfxStringItem* pUrlItem = _rDest.GetItem(DSID_DOCUMENT_URL); - OSL_ENSURE(pUrlItem,"Document URL is NULL. -> GPF!"); + assert(pUrlItem && "Document URL is NULL. -> GPF!"); return pUrlItem->GetValue(); } @@ -1007,10 +1007,10 @@ void ODbDataSourceAdministrationHelper::convertUrl(SfxItemSet& _rDest) const SfxStringItem* pUrlItem = _rDest.GetItem(DSID_CONNECTURL); const DbuTypeCollectionItem* pTypeCollection = _rDest.GetItem(DSID_TYPECOLLECTION); - OSL_ENSURE(pUrlItem,"Connection URL is NULL. -> GPF!"); - OSL_ENSURE(pTypeCollection, "ODbAdminDialog::getDatasourceType: invalid items in the source set!"); + assert(pUrlItem && "Connection URL is NULL. -> GPF!"); + assert(pTypeCollection && "ODbAdminDialog::getDatasourceType: invalid items in the source set!"); ::dbaccess::ODsnTypeCollection* pCollection = pTypeCollection->getCollection(); - OSL_ENSURE(pCollection, "ODbAdminDialog::getDatasourceType: invalid type collection!"); + assert(pCollection && "ODbAdminDialog::getDatasourceType: invalid type collection!"); TypedWhichId nPortNumberId(0); sal_Int32 nPortNumber = -1; diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx index fe6eb7fd62de..07891f773cfd 100644 --- a/dbaccess/source/ui/dlg/sqlmessage.cxx +++ b/dbaccess/source/ui/dlg/sqlmessage.cxx @@ -207,7 +207,7 @@ namespace iter.next( aCurrentElement ); const SQLException* pCurrentError = aCurrentElement; - OSL_ENSURE( pCurrentError, "lcl_buildExceptionChain: iterator failure!" ); + assert(pCurrentError && "lcl_buildExceptionChain: iterator failure!"); // hasMoreElements should not have returned in this case ExceptionDisplayInfo aDisplayInfo( aCurrentElement.getType() ); diff --git a/dbaccess/source/ui/querydesign/QTableConnectionData.cxx b/dbaccess/source/ui/querydesign/QTableConnectionData.cxx index ce66828facb5..a42d65508008 100644 --- a/dbaccess/source/ui/querydesign/QTableConnectionData.cxx +++ b/dbaccess/source/ui/querydesign/QTableConnectionData.cxx @@ -87,8 +87,8 @@ void OQueryTableConnectionData::InitFromDrag(const OTableFieldDescRef& rDragLeft // convert Information in rDrag into parameters for the base class init OQueryTableWindow* pSourceWin = static_cast(rDragLeft->GetTabWindow()); OQueryTableWindow* pDestWin = static_cast(rDragRight->GetTabWindow()); - OSL_ENSURE(pSourceWin,"NO Source window found!"); - OSL_ENSURE(pDestWin,"NO Dest window found!"); + assert(pSourceWin && "NO Source window found!"); + assert(pDestWin && "NO Dest window found!"); m_pReferencingTable = pSourceWin->GetData(); m_pReferencedTable = pDestWin->GetData(); diff --git a/dbaccess/source/ui/querydesign/QTableWindow.cxx b/dbaccess/source/ui/querydesign/QTableWindow.cxx index 93cbf6026d4c..ed490860c3ea 100644 --- a/dbaccess/source/ui/querydesign/QTableWindow.cxx +++ b/dbaccess/source/ui/querydesign/QTableWindow.cxx @@ -110,7 +110,7 @@ void OQueryTableWindow::OnEntryDoubleClicked(weld::TreeIter& rEntry) weld::TreeView& rTreeView = m_xListBox->get_widget(); OTableFieldInfo* pInf = weld::fromId(rTreeView.get_id(rEntry)); - OSL_ENSURE(pInf != nullptr, "OQueryTableWindow::OnEntryDoubleClicked : field doesn't have FieldInfo !"); + assert(pInf && "OQueryTableWindow::OnEntryDoubleClicked : field doesn't have FieldInfo !"); // build up DragInfo OTableFieldDescRef aInfo = new OTableFieldDesc(GetTableName(), rTreeView.get_text(rEntry)); diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 108d36fd5729..47c7a996be94 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -309,7 +309,7 @@ namespace const OQueryTableWindow* _pEntryTabTo, OUString& _rJoin ) { - OSL_ENSURE(_pEntryConn,"TableConnection can not be null!"); + assert(_pEntryConn && "TableConnection can not be null!"); OQueryTableConnectionData* pData = static_cast< OQueryTableConnectionData*>(_pEntryConn->GetData().get()); if ( !(pData->GetJoinType() != INNER_JOIN && _pEntryTabTo->ExistsAVisitedConn()) ) diff --git a/dbaccess/source/ui/querydesign/QueryTableView.cxx b/dbaccess/source/ui/querydesign/QueryTableView.cxx index 663d3a9e65a6..f48dc17c7a3a 100644 --- a/dbaccess/source/ui/querydesign/QueryTableView.cxx +++ b/dbaccess/source/ui/querydesign/QueryTableView.cxx @@ -496,7 +496,7 @@ void OQueryTableView::AddTabWin(const OUString& _rComposedName, const OUString& if ( pTabWinTmp->GetData()->isQuery() ) continue; - OSL_ENSURE(pTabWinTmp,"TableWindow is null!"); + assert(pTabWinTmp && "TableWindow is null!"); Reference< XPropertySet > xFKKey = getKeyReferencedTo( pTabWinTmp->GetData()->getKeys(), pNewTabWin->GetComposedName() ); if ( !xFKKey.is() ) continue; @@ -751,7 +751,7 @@ void OQueryTableView::HideTabWin( OQueryTableWindow* pTabWin, OQueryTabWinUndoAc { VclPtr xTmpEntry = *aIter2; OQueryTableConnection* pTmpEntry = static_cast(xTmpEntry.get()); - OSL_ENSURE(pTmpEntry,"OQueryTableConnection is null!"); + assert(pTmpEntry && "OQueryTableConnection is null!"); if( pTmpEntry->GetAliasName(JTCS_FROM) == pTabWin->GetAliasName() || pTmpEntry->GetAliasName(JTCS_TO) == pTabWin->GetAliasName() ) { diff --git a/dbaccess/source/ui/querydesign/TableWindowTitle.cxx b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx index 0e3ad0573c7f..2990a010298b 100644 --- a/dbaccess/source/ui/querydesign/TableWindowTitle.cxx +++ b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx @@ -64,7 +64,7 @@ IMPL_LINK(OTableWindowTitle, MousePressHdl, const MouseEvent&, rEvt, bool) m_pTabWin->SetSizePixel(aSize); OJoinTableView* pView = m_pTabWin->getTableView(); - OSL_ENSURE(pView,"No OJoinTableView!"); + assert(pView && "No OJoinTableView!"); for (auto& conn : pView->getTableConnections()) conn->RecalcLines(); -- cgit