diff options
author | Noel Grandin <noel@peralex.com> | 2016-03-17 10:04:45 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-03-17 10:33:08 +0000 |
commit | 2a78e3eb92466ede9ea8fd3c3632c286fbd915a2 (patch) | |
tree | ff618d7e1a958475455ce1939ab26f30b3c0de29 /sot | |
parent | ce66911720b3245b21fb14bb83619c42610e5ac6 (diff) |
loplugin:constantparam in sot
Change-Id: I380b5a824b1bc8cd322471519d2d87ab7f2bca1c
Reviewed-on: https://gerrit.libreoffice.org/23320
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'sot')
-rw-r--r-- | sot/source/sdstor/stgcache.cxx | 18 | ||||
-rw-r--r-- | sot/source/sdstor/stgcache.hxx | 4 | ||||
-rw-r--r-- | sot/source/sdstor/stgdir.cxx | 8 | ||||
-rw-r--r-- | sot/source/sdstor/stgstrms.cxx | 12 | ||||
-rw-r--r-- | sot/source/sdstor/stgstrms.hxx | 4 | ||||
-rw-r--r-- | sot/source/sdstor/storage.cxx | 4 |
6 files changed, 24 insertions, 26 deletions
diff --git a/sot/source/sdstor/stgcache.cxx b/sot/source/sdstor/stgcache.cxx index 832fde7406e2..9360ce184f88 100644 --- a/sot/source/sdstor/stgcache.cxx +++ b/sot/source/sdstor/stgcache.cxx @@ -173,7 +173,7 @@ rtl::Reference< StgPage > StgCache::Get( sal_Int32 nPage, bool bForce ) if( !p.is() ) { p = Create( nPage ); - if( !Read( nPage, p->GetData(), 1 ) && bForce ) + if( !Read( nPage, p->GetData() ) && bForce ) { Erase( p ); p.clear(); @@ -223,7 +223,7 @@ bool StgCache::Commit() aWr != aToWrite.end(); ++aWr) { const rtl::Reference< StgPage > &pPage = *aWr; - if ( !Write( pPage->GetPage(), pPage->GetData(), 1 ) ) + if ( !Write( pPage->GetPage(), pPage->GetData() ) ) return false; } } @@ -318,7 +318,7 @@ void StgCache::Close() // low level I/O -bool StgCache::Read( sal_Int32 nPage, void* pBuf, sal_Int32 nPg ) +bool StgCache::Read( sal_Int32 nPage, void* pBuf ) { if( Good() ) { @@ -331,21 +331,21 @@ bool StgCache::Read( sal_Int32 nPage, void* pBuf, sal_Int32 nPg ) else if ( nPage < m_nPages ) { sal_uInt32 nPos = Page2Pos( nPage ); - sal_Int32 nPg2 = ( ( nPage + nPg ) > m_nPages ) ? m_nPages - nPage : nPg; + sal_Int32 nPg2 = ( ( nPage + 1 ) > m_nPages ) ? m_nPages - nPage : 1; sal_uInt32 nBytes = nPg2 * m_nPageSize; // fixed address and size for the header if( nPage == -1 ) { nPos = 0L; nBytes = 512; - nPg2 = nPg; + nPg2 = 1; } if( m_pStrm->Tell() != nPos ) { m_pStrm->Seek(nPos); } m_pStrm->Read( pBuf, nBytes ); - if ( nPg != nPg2 ) + if ( 1 != nPg2 ) SetError( SVSTREAM_READ_ERROR ); else SetError( m_pStrm->GetError() ); @@ -354,14 +354,12 @@ bool StgCache::Read( sal_Int32 nPage, void* pBuf, sal_Int32 nPg ) return Good(); } -bool StgCache::Write( sal_Int32 nPage, void* pBuf, sal_Int32 nPg ) +bool StgCache::Write( sal_Int32 nPage, void* pBuf ) { if( Good() ) { sal_uInt32 nPos = Page2Pos( nPage ); - sal_uInt32 nBytes = 0; - if ( SAL_MAX_INT32 / nPg > m_nPageSize ) - nBytes = nPg * m_nPageSize; + sal_uInt32 nBytes = m_nPageSize; // fixed address and size for the header // nPageSize must be >= 512, otherwise the header can not be written here, we check it on import diff --git a/sot/source/sdstor/stgcache.hxx b/sot/source/sdstor/stgcache.hxx index 9911f4b4cc7d..3c0d866524a0 100644 --- a/sot/source/sdstor/stgcache.hxx +++ b/sot/source/sdstor/stgcache.hxx @@ -79,8 +79,8 @@ public: void ResetError(); bool Open( const OUString& rName, StreamMode ); void Close(); - bool Read( sal_Int32 nPage, void* pBuf, sal_Int32 nPages ); - bool Write( sal_Int32 nPage, void* pBuf, sal_Int32 nPages ); + bool Read( sal_Int32 nPage, void* pBuf ); + bool Write( sal_Int32 nPage, void* pBuf ); // two routines for accessing FAT pages // Assume that the data is a FAT page and get/put FAT data. diff --git a/sot/source/sdstor/stgdir.cxx b/sot/source/sdstor/stgdir.cxx index e093936d2a16..39845250c343 100644 --- a/sot/source/sdstor/stgdir.cxx +++ b/sot/source/sdstor/stgdir.cxx @@ -346,7 +346,7 @@ bool StgDirEntry::SetSize( sal_Int32 nNewSize ) { pOld = m_pStgStrm; nOldSize = (sal_uInt16) nNewSize; - m_pStgStrm = new StgSmallStrm( rIo, STG_EOF, 0 ); + m_pStgStrm = new StgSmallStrm( rIo, STG_EOF ); } // now set the new size if( m_pStgStrm->SetSize( nNewSize ) ) @@ -635,9 +635,9 @@ bool StgDirEntry::Tmp2Strm() StgIo& rIo = m_pStgStrm->GetIo(); sal_uLong nThreshold = (sal_uLong) rIo.m_aHdr.GetThreshold(); if( n < nThreshold ) - pNewStrm = new StgSmallStrm( rIo, STG_EOF, 0 ); + pNewStrm = new StgSmallStrm( rIo, STG_EOF ); else - pNewStrm = new StgDataStrm( rIo, STG_EOF, 0 ); + pNewStrm = new StgDataStrm( rIo, STG_EOF ); if( pNewStrm->SetSize( n ) ) { sal_uInt8 p[ 4096 ]; @@ -924,7 +924,7 @@ bool StgDirStrm::Store() void* StgDirStrm::GetEntry( sal_Int32 n, bool bDirty ) { return n < 0 || n >= m_nSize / STGENTRY_SIZE - ? nullptr : GetPtr( n * STGENTRY_SIZE, true, bDirty ); + ? nullptr : GetPtr( n * STGENTRY_SIZE, bDirty ); } // Find a dir entry. diff --git a/sot/source/sdstor/stgstrms.cxx b/sot/source/sdstor/stgstrms.cxx index ffc27a4f52fa..4f749486c1cc 100644 --- a/sot/source/sdstor/stgstrms.cxx +++ b/sot/source/sdstor/stgstrms.cxx @@ -871,11 +871,11 @@ bool StgDataStrm::SetSize( sal_Int32 nBytes ) // If bForce = true, a read of non-existent data causes // a read fault. -void* StgDataStrm::GetPtr( sal_Int32 Pos, bool bForce, bool bDirty ) +void* StgDataStrm::GetPtr( sal_Int32 Pos, bool bDirty ) { if( Pos2Page( Pos ) ) { - rtl::Reference< StgPage > pPg = m_rIo.Get( m_nPage, bForce ); + rtl::Reference< StgPage > pPg = m_rIo.Get( m_nPage, true/*bForce*/ ); if (pPg.is() && m_nOffset < pPg->GetSize()) { if( bDirty ) @@ -919,7 +919,7 @@ sal_Int32 StgDataStrm::Read( void* pBuf, sal_Int32 n ) } else // do a direct (unbuffered) read - nRes = (short) m_rIo.Read( m_nPage, p, 1 ) * m_nPageSize; + nRes = (short) m_rIo.Read( m_nPage, p ) * m_nPageSize; } else { @@ -979,7 +979,7 @@ sal_Int32 StgDataStrm::Write( const void* pBuf, sal_Int32 n ) } else // do a direct (unbuffered) write - nRes = (short) m_rIo.Write( m_nPage, const_cast<void*>(p), 1 ) * m_nPageSize; + nRes = (short) m_rIo.Write( m_nPage, const_cast<void*>(p) ) * m_nPageSize; } else { @@ -1012,9 +1012,9 @@ sal_Int32 StgDataStrm::Write( const void* pBuf, sal_Int32 n ) // is also a StgStream. The start of the FAT is in the header at DataRootPage, // the stream itself is pointed to by the root entry (it holds start & size). -StgSmallStrm::StgSmallStrm( StgIo& r, sal_Int32 nBgn, sal_Int32 nLen ) : StgStrm( r ) +StgSmallStrm::StgSmallStrm( StgIo& r, sal_Int32 nBgn ) : StgStrm( r ) { - Init( nBgn, nLen ); + Init( nBgn, 0 ); } StgSmallStrm::StgSmallStrm( StgIo& r, StgDirEntry& p ) : StgStrm( r ) diff --git a/sot/source/sdstor/stgstrms.hxx b/sot/source/sdstor/stgstrms.hxx index ad544f032a93..808fc0a7b3df 100644 --- a/sot/source/sdstor/stgstrms.hxx +++ b/sot/source/sdstor/stgstrms.hxx @@ -116,7 +116,7 @@ class StgDataStrm : public StgStrm // a physical data stream public: StgDataStrm( StgIo&, sal_Int32 nBgn, sal_Int32 nLen=-1 ); StgDataStrm( StgIo&, StgDirEntry& ); - void* GetPtr( sal_Int32 nPos, bool bForce, bool bDirty ); + void* GetPtr( sal_Int32 nPos, bool bDirty ); void SetIncrement( short n ) { m_nIncr = n ; } virtual bool SetSize( sal_Int32 ) override; virtual sal_Int32 Read( void*, sal_Int32 ) override; @@ -133,7 +133,7 @@ class StgSmallStrm : public StgStrm // a logical data stream StgStrm* m_pData; // the data stream void Init( sal_Int32 nBgn, sal_Int32 nLen ); public: - StgSmallStrm( StgIo&, sal_Int32 nBgn, sal_Int32 nLen ); + StgSmallStrm( StgIo&, sal_Int32 nBgn ); StgSmallStrm( StgIo&, StgDirEntry& ); virtual sal_Int32 Read( void*, sal_Int32 ) override; virtual sal_Int32 Write( const void*, sal_Int32 ) override; diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx index 9abf9ccda276..936a7cf32a19 100644 --- a/sot/source/sdstor/storage.cxx +++ b/sot/source/sdstor/storage.cxx @@ -294,11 +294,11 @@ SotStorage::SotStorage() #include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <ucbhelper/content.hxx> -SotStorage::SotStorage( const OUString & rName, StreamMode nMode, bool transacted ) +SotStorage::SotStorage( const OUString & rName, StreamMode nMode ) INIT_SotStorage() { m_aName = rName; // Namen merken - CreateStorage( true, nMode, transacted ); + CreateStorage( true, nMode, false ); if ( IsOLEStorage() ) m_nVersion = SOFFICE_FILEFORMAT_50; } |