[Libreoffice-commits] core.git: tools/source

Fakabbir Amin fakabbir at gmail.com
Mon May 8 14:58:59 UTC 2017


 tools/source/ref/pstm.cxx |   24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

New commits:
commit f9f0b6ac12c5d6c73d9aa415a9de5e37105085d8
Author: Fakabbir Amin <fakabbir at gmail.com>
Date:   Fri Feb 3 17:44:40 2017 +0530

    tdf#43157 Cleanup DBG_ASSERT in pstm.cxx
    
    Change-Id: Ibc7b7399ccc827168768ee94b6e75e4116fc95c9
    Reviewed-on: https://gerrit.libreoffice.org/33882
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/tools/source/ref/pstm.cxx b/tools/source/ref/pstm.cxx
index c025ed96e132..5e9a7b450f3d 100644
--- a/tools/source/ref/pstm.cxx
+++ b/tools/source/ref/pstm.cxx
@@ -17,10 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <tools/debug.hxx>
 #include <tools/pstm.hxx>
 #include <rtl/strbuf.hxx>
 #include <osl/diagnose.h>
+#include <sal/log.hxx>
 
 #define STOR_NO_OPTIMIZE
 
@@ -29,7 +29,7 @@ void SvClassManager::Register( sal_Int32 nClassId, SvCreateInstancePersist pFunc
 #ifdef DBG_UTIL
     SvCreateInstancePersist p;
     p = Get( nClassId );
-    DBG_ASSERT( !p || p == pFunc, "register class with same id" );
+    assert( (!p || p == pFunc) && "register class with same id");
 #endif
     aAssocTable.insert(Map::value_type(nClassId, pFunc));
 }
@@ -57,7 +57,6 @@ SvPersistStream::SvPersistStream( SvClassManager & rMgr, SvStream * pStream )
     , aPUIdx( UniqueIndex<SvPersistBase>::Index(1) )
     , nStartIdx( 1 )
 {
-    DBG_ASSERT( nStartIdx != Index(0), "zero index not allowed" );
     m_isWritable = true;
     if( pStm )
     {
@@ -80,13 +79,13 @@ SvPersistStream::~SvPersistStream()
 void SvPersistStream::ResetError()
 {
     SvStream::ResetError();
-    DBG_ASSERT( pStm, "stream not set" );
+    assert(pStm && "stream not set");
     pStm->ResetError();
 }
 
 std::size_t SvPersistStream::GetData( void* pData, std::size_t nSize )
 {
-    DBG_ASSERT( pStm, "stream not set" );
+    assert(pStm && "stream not set");
     std::size_t const nRet = pStm->ReadBytes( pData, nSize );
     SetError( pStm->GetError() );
     return nRet;
@@ -94,7 +93,7 @@ std::size_t SvPersistStream::GetData( void* pData, std::size_t nSize )
 
 std::size_t SvPersistStream::PutData( const void* pData, std::size_t nSize )
 {
-    DBG_ASSERT( pStm, "stream not set" );
+    assert(pStm && "stream not set");
     std::size_t const nRet = pStm->WriteBytes( pData, nSize );
     SetError( pStm->GetError() );
     return nRet;
@@ -102,7 +101,7 @@ std::size_t SvPersistStream::PutData( const void* pData, std::size_t nSize )
 
 sal_uInt64 SvPersistStream::SeekPos(sal_uInt64 const nPos)
 {
-    DBG_ASSERT( pStm, "stream not set" );
+    assert(pStm && "stream not set");
     sal_uInt64 nRet = pStm->Seek( nPos );
     SetError( pStm->GetError() );
     return nRet;
@@ -446,8 +445,7 @@ void SvPersistStream::ReadObj
     {
         if( P_OBJ & nHdr )
         { // read object, nId only set for P_DBGUTIL
-            DBG_ASSERT( !(nHdr & P_DBGUTIL) || nullptr == aPUIdx.Get( nId ),
-                        "object already exist" );
+            SAL_WARN_IF( (nHdr & P_DBGUTIL) && nullptr != aPUIdx.Get( nId ), "tools","object already exists");
             SvCreateInstancePersist pFunc = rClassMgr.Get( nClassId );
 
             sal_uInt32 nObjLen(0), nObjPos(0);
@@ -474,8 +472,8 @@ void SvPersistStream::ReadObj
             const Index nNewId = aPUIdx.Insert( rpObj );
             // in order to restore state after saving
             aPTable[ rpObj ] = nNewId;
-            DBG_ASSERT( !(nHdr & P_DBGUTIL) || nId == nNewId,
-                        "read write id conflict: not the same" );
+            SAL_WARN_IF( (nHdr & P_DBGUTIL) && (nId != nNewId), "tools","read write id conflict: not the same");
+
             rpObj->Load( *this );
 #ifdef DBG_UTIL
             if( nObjLen + nObjPos != Tell() )
@@ -493,8 +491,8 @@ void SvPersistStream::ReadObj
         else
         {
             rpObj = GetObject( nId );
-            DBG_ASSERT( rpObj != nullptr, "object does not exist" );
-            DBG_ASSERT( rpObj->GetClassId() == nClassId, "class mismatch" );
+            SAL_WARN_IF(rpObj==nullptr,"tools","object does not exist");
+            SAL_WARN_IF( rpObj->GetClassId() != nClassId , "tools" , "class mismatch" );
         }
     }
 }


More information about the Libreoffice-commits mailing list