diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-12-12 09:42:47 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-12-12 11:49:03 +0000 |
commit | 2c2e80da68efcee5bffdb61d9c078f9360a639a4 (patch) | |
tree | ecd55cd5c97f1dbe2580d033c0fcda6568ff849f /package | |
parent | c928840ef2a41ca373ad9070d8e9160c216260da (diff) |
callcatcher: remove newly unused code
and rework reads to just return the read value
Change-Id: I5d2f01064465c65859ec4ba031ec9dfa16403487
Diffstat (limited to 'package')
-rw-r--r-- | package/inc/ByteChucker.hxx | 37 | ||||
-rw-r--r-- | package/inc/ByteGrabber.hxx | 16 | ||||
-rw-r--r-- | package/source/zipapi/ByteChucker.cxx | 47 | ||||
-rw-r--r-- | package/source/zipapi/ByteGrabber.cxx | 90 | ||||
-rw-r--r-- | package/source/zipapi/MemoryByteGrabber.hxx | 79 | ||||
-rw-r--r-- | package/source/zipapi/ZipFile.cxx | 87 |
6 files changed, 129 insertions, 227 deletions
diff --git a/package/inc/ByteChucker.hxx b/package/inc/ByteChucker.hxx index 7e3e60c0ce65..e317e8acd6c4 100644 --- a/package/inc/ByteChucker.hxx +++ b/package/inc/ByteChucker.hxx @@ -48,12 +48,37 @@ public: sal_Int64 GetPosition() throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); - ByteChucker& WriteInt8(sal_Int8 nInt8); - ByteChucker& WriteInt16(sal_Int16 nInt16); - ByteChucker& WriteInt32(sal_Int32 nInt32); - ByteChucker& WriteUInt8(sal_uInt8 nuInt8); - ByteChucker& WriteUInt16(sal_uInt16 nuInt16); - ByteChucker& WriteUInt32(sal_uInt32 nuInt32); + void WriteInt16(sal_Int16 nInt16) + { + p2Sequence[0] = static_cast< sal_Int8 >((nInt16 >> 0 ) & 0xFF); + p2Sequence[1] = static_cast< sal_Int8 >((nInt16 >> 8 ) & 0xFF); + WriteBytes( a2Sequence ); + } + + void WriteInt32(sal_Int32 nInt32) + { + p4Sequence[0] = static_cast< sal_Int8 >((nInt32 >> 0 ) & 0xFF); + p4Sequence[1] = static_cast< sal_Int8 >((nInt32 >> 8 ) & 0xFF); + p4Sequence[2] = static_cast< sal_Int8 >((nInt32 >> 16 ) & 0xFF); + p4Sequence[3] = static_cast< sal_Int8 >((nInt32 >> 24 ) & 0xFF); + WriteBytes( a4Sequence ); + } + + void WriteUInt16(sal_uInt16 nuInt16) + { + p2Sequence[0] = static_cast< sal_Int8 >((nuInt16 >> 0 ) & 0xFF); + p2Sequence[1] = static_cast< sal_Int8 >((nuInt16 >> 8 ) & 0xFF); + WriteBytes( a2Sequence ); + } + + void WriteUInt32(sal_uInt32 nuInt32) + { + p4Sequence[0] = static_cast < sal_Int8 > ((nuInt32 >> 0 ) & 0xFF); + p4Sequence[1] = static_cast < sal_Int8 > ((nuInt32 >> 8 ) & 0xFF); + p4Sequence[2] = static_cast < sal_Int8 > ((nuInt32 >> 16 ) & 0xFF); + p4Sequence[3] = static_cast < sal_Int8 > ((nuInt32 >> 24 ) & 0xFF); + WriteBytes( a4Sequence ); + } }; #endif diff --git a/package/inc/ByteGrabber.hxx b/package/inc/ByteGrabber.hxx index 26df1b19a131..2791e0bfd6c7 100644 --- a/package/inc/ByteGrabber.hxx +++ b/package/inc/ByteGrabber.hxx @@ -58,12 +58,16 @@ public: sal_Int64 SAL_CALL getLength( ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); - ByteGrabber& ReadInt8(sal_Int8& rInt8); - ByteGrabber& ReadInt16(sal_Int16& rInt16); - ByteGrabber& ReadInt32(sal_Int32& rInt32); - ByteGrabber& ReadUInt8(sal_uInt8& ruInt8); - ByteGrabber& ReadUInt16(sal_uInt16& ruInt16); - ByteGrabber& ReadUInt32(sal_uInt32& ruInt32); + sal_uInt16 ReadUInt16(); + sal_uInt32 ReadUInt32(); + sal_Int16 ReadInt16() + { + return static_cast<sal_Int16>(ReadUInt16()); + } + sal_Int32 ReadInt32() + { + return static_cast<sal_Int32>(ReadUInt32()); + } }; #endif diff --git a/package/source/zipapi/ByteChucker.cxx b/package/source/zipapi/ByteChucker.cxx index 5bcf64272a5e..8354c7cf5e7c 100644 --- a/package/source/zipapi/ByteChucker.cxx +++ b/package/source/zipapi/ByteChucker.cxx @@ -54,51 +54,4 @@ sal_Int64 ByteChucker::GetPosition( ) return xSeek->getPosition(); } -ByteChucker& ByteChucker::WriteInt8(sal_Int8 nInt8) -{ - p1Sequence[0] = nInt8 & 0xFF; - WriteBytes( a1Sequence ); - return *this; -} - -ByteChucker& ByteChucker::WriteInt16(sal_Int16 nInt16) -{ - p2Sequence[0] = static_cast< sal_Int8 >((nInt16 >> 0 ) & 0xFF); - p2Sequence[1] = static_cast< sal_Int8 >((nInt16 >> 8 ) & 0xFF); - WriteBytes( a2Sequence ); - return *this; -} -ByteChucker& ByteChucker::WriteInt32(sal_Int32 nInt32) -{ - p4Sequence[0] = static_cast< sal_Int8 >((nInt32 >> 0 ) & 0xFF); - p4Sequence[1] = static_cast< sal_Int8 >((nInt32 >> 8 ) & 0xFF); - p4Sequence[2] = static_cast< sal_Int8 >((nInt32 >> 16 ) & 0xFF); - p4Sequence[3] = static_cast< sal_Int8 >((nInt32 >> 24 ) & 0xFF); - WriteBytes( a4Sequence ); - return *this; -} - -ByteChucker& ByteChucker::WriteUInt8(sal_uInt8 nuInt8) -{ - p1Sequence[0] = nuInt8 & 0xFF; - WriteBytes( a1Sequence ); - return *this; -} -ByteChucker& ByteChucker::WriteUInt16(sal_uInt16 nuInt16) -{ - p2Sequence[0] = static_cast< sal_Int8 >((nuInt16 >> 0 ) & 0xFF); - p2Sequence[1] = static_cast< sal_Int8 >((nuInt16 >> 8 ) & 0xFF); - WriteBytes( a2Sequence ); - return *this; -} -ByteChucker& ByteChucker::WriteUInt32(sal_uInt32 nuInt32) -{ - p4Sequence[0] = static_cast < sal_Int8 > ((nuInt32 >> 0 ) & 0xFF); - p4Sequence[1] = static_cast < sal_Int8 > ((nuInt32 >> 8 ) & 0xFF); - p4Sequence[2] = static_cast < sal_Int8 > ((nuInt32 >> 16 ) & 0xFF); - p4Sequence[3] = static_cast < sal_Int8 > ((nuInt32 >> 24 ) & 0xFF); - WriteBytes( a4Sequence ); - return *this; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/package/source/zipapi/ByteGrabber.cxx b/package/source/zipapi/ByteGrabber.cxx index 9b47a364fd55..65643bee865d 100644 --- a/package/source/zipapi/ByteGrabber.cxx +++ b/package/source/zipapi/ByteGrabber.cxx @@ -100,90 +100,32 @@ sal_Int64 SAL_CALL ByteGrabber::getLength( ) throw io::IOException(THROW_WHERE ); } -ByteGrabber& ByteGrabber::ReadInt8(sal_Int8& rInt8) +sal_uInt16 ByteGrabber::ReadUInt16() { ::osl::MutexGuard aGuard( m_aMutex ); - if (xStream->readBytes(aSequence,1) != 1) - rInt8 = 0; - else - rInt8 = aSequence[0] & 0xFF; - return *this; -} - -ByteGrabber& ByteGrabber::ReadInt16(sal_Int16& rInt16) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - if (xStream->readBytes ( aSequence, 2) != 2) - rInt16 = 0; - else - { - pSequence = aSequence.getConstArray(); - rInt16 = static_cast <sal_Int16> - ( (pSequence[0] & 0xFF) - | (pSequence[1] & 0xFF) << 8); - } - return *this; -} - -ByteGrabber& ByteGrabber::ReadInt32(sal_Int32& rInt32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - if (xStream->readBytes(aSequence, 4) != 4) - rInt32 = 0; - else - { - pSequence = aSequence.getConstArray(); - rInt32 = static_cast < sal_Int32 > - ( (pSequence[0] & 0xFF) - | ( pSequence[1] & 0xFF ) << 8 - | ( pSequence[2] & 0xFF ) << 16 - | ( pSequence[3] & 0xFF ) << 24 ); - } - return *this; -} -ByteGrabber& ByteGrabber::ReadUInt8(sal_uInt8& rInt8) -{ - ::osl::MutexGuard aGuard( m_aMutex ); + if (xStream->readBytes(aSequence, 2) != 2) + return 0; - if (xStream->readBytes(aSequence,1) != 1) - rInt8 = 0; - else - rInt8 = static_cast < sal_uInt8 > (aSequence[0] & 0xFF ); - return *this; + pSequence = aSequence.getConstArray(); + return static_cast <sal_uInt16> + ( (pSequence[0] & 0xFF) + | (pSequence[1] & 0xFF) << 8); } -ByteGrabber& ByteGrabber::ReadUInt16(sal_uInt16& rInt16) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - if (xStream->readBytes(aSequence, 2) != 2) - rInt16 = 0; - else - { - pSequence = aSequence.getConstArray(); - rInt16 = static_cast <sal_uInt16> - ( (pSequence[0] & 0xFF) - | (pSequence[1] & 0xFF) << 8); - } - return *this; -} -ByteGrabber& ByteGrabber::ReadUInt32(sal_uInt32& ruInt32) +sal_uInt32 ByteGrabber::ReadUInt32() { ::osl::MutexGuard aGuard( m_aMutex ); if (xStream->readBytes(aSequence, 4) != 4) - ruInt32 = 0; - else - { - pSequence = aSequence.getConstArray(); - ruInt32 = static_cast < sal_uInt32 > - ( (pSequence[0] & 0xFF) - | ( pSequence[1] & 0xFF ) << 8 - | ( pSequence[2] & 0xFF ) << 16 - | ( pSequence[3] & 0xFF ) << 24 ); - } - return *this; + return 0; + + pSequence = aSequence.getConstArray(); + return static_cast < sal_uInt32 > + ( (pSequence[0] & 0xFF) + | ( pSequence[1] & 0xFF ) << 8 + | ( pSequence[2] & 0xFF ) << 16 + | ( pSequence[3] & 0xFF ) << 24 ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/package/source/zipapi/MemoryByteGrabber.hxx b/package/source/zipapi/MemoryByteGrabber.hxx index 318b93c78594..5a1b1eb5e211 100644 --- a/package/source/zipapi/MemoryByteGrabber.hxx +++ b/package/source/zipapi/MemoryByteGrabber.hxx @@ -99,70 +99,57 @@ public: { return mnEnd; } - MemoryByteGrabber& ReadInt8(sal_Int8& rInt8) + sal_Int8 ReadInt8() { if (mnCurrent + 1 > mnEnd ) - rInt8 = 0; - else - rInt8 = mpBuffer [mnCurrent++] & 0xFF; - return *this; + return 0; + return mpBuffer [mnCurrent++] & 0xFF; } - MemoryByteGrabber& ReadInt16(sal_Int16& rInt16) + sal_Int16 ReadInt16() { if (mnCurrent + 2 > mnEnd ) - rInt16 = 0; - else - { - rInt16 = mpBuffer[mnCurrent++] & 0xFF; - rInt16 |= ( mpBuffer[mnCurrent++] & 0xFF ) << 8; - } - return *this; + return 0; + sal_Int16 nInt16 = mpBuffer[mnCurrent++] & 0xFF; + nInt16 |= ( mpBuffer[mnCurrent++] & 0xFF ) << 8; + return nInt16; } - MemoryByteGrabber& ReadInt32(sal_Int32& rInt32) + sal_Int32 ReadInt32() { if (mnCurrent + 4 > mnEnd ) - rInt32 = 0; - else - { - rInt32 = mpBuffer[mnCurrent++] & 0xFF; - rInt32 |= ( mpBuffer[mnCurrent++] & 0xFF ) << 8; - rInt32 |= ( mpBuffer[mnCurrent++] & 0xFF ) << 16; - rInt32 |= ( mpBuffer[mnCurrent++] & 0xFF ) << 24; - } - return *this; + return 0; + + sal_Int32 nInt32 = mpBuffer[mnCurrent++] & 0xFF; + nInt32 |= ( mpBuffer[mnCurrent++] & 0xFF ) << 8; + nInt32 |= ( mpBuffer[mnCurrent++] & 0xFF ) << 16; + nInt32 |= ( mpBuffer[mnCurrent++] & 0xFF ) << 24; + return nInt32; } - MemoryByteGrabber& ReadUInt8(sal_uInt8& rInt8) + sal_uInt8 ReadUInt8() { if (mnCurrent + 1 > mnEnd ) - rInt8 = 0; - else - rInt8 = mpBuffer [mnCurrent++] & 0xFF; - return *this; + return 0; + return mpBuffer [mnCurrent++] & 0xFF; } - MemoryByteGrabber& ReadUInt16(sal_uInt16& rInt16) + sal_uInt16 ReadUInt16() { if (mnCurrent + 2 > mnEnd ) - rInt16 = 0; - else - { - rInt16 = mpBuffer [mnCurrent++] & 0xFF; - rInt16 |= ( mpBuffer [mnCurrent++] & 0xFF ) << 8; - } - return *this; + return 0; + + sal_uInt16 nInt16 = mpBuffer [mnCurrent++] & 0xFF; + nInt16 |= ( mpBuffer [mnCurrent++] & 0xFF ) << 8; + return nInt16; } - MemoryByteGrabber& ReadUInt32(sal_uInt32& rInt32) + sal_uInt32 ReadUInt32() { if (mnCurrent + 4 > mnEnd ) - rInt32 = 0; - else - { - rInt32 = mpBuffer [mnCurrent++] & 0xFF; - rInt32 |= ( mpBuffer [mnCurrent++] & 0xFF ) << 8; - rInt32 |= ( mpBuffer [mnCurrent++] & 0xFF ) << 16; - rInt32 |= ( mpBuffer [mnCurrent++] & 0xFF ) << 24; - } - return *this; + return 0; + + sal_uInt32 nInt32 = mpBuffer [mnCurrent++] & 0xFF; + nInt32 |= ( mpBuffer [mnCurrent++] & 0xFF ) << 8; + nInt32 |= ( mpBuffer [mnCurrent++] & 0xFF ) << 16; + nInt32 |= ( mpBuffer [mnCurrent++] & 0xFF ) << 24; + return nInt32; } }; diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx index 0fe8ff29a247..a860f058a478 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -634,24 +634,22 @@ bool ZipFile::readLOC( ZipEntry &rEntry ) { ::osl::MutexGuard aGuard( m_aMutex ); - sal_Int32 nTestSig, nTime, nCRC, nSize, nCompressedSize; - sal_Int16 nVersion, nFlag, nHow, nPathLen, nExtraLen; sal_Int64 nPos = -rEntry.nOffset; aGrabber.seek(nPos); - aGrabber.ReadInt32( nTestSig ); + sal_Int32 nTestSig = aGrabber.ReadInt32(); if (nTestSig != LOCSIG) throw ZipIOException("Invalid LOC header (bad signature)" ); - aGrabber.ReadInt16( nVersion ); - aGrabber.ReadInt16( nFlag ); - aGrabber.ReadInt16( nHow ); - aGrabber.ReadInt32( nTime ); - aGrabber.ReadInt32( nCRC ); - aGrabber.ReadInt32( nCompressedSize ); - aGrabber.ReadInt32( nSize ); - aGrabber.ReadInt16( nPathLen ); - aGrabber.ReadInt16( nExtraLen ); + sal_Int16 nVersion = aGrabber.ReadInt16(); + aGrabber.ReadInt16(); //flag + aGrabber.ReadInt16(); //how + aGrabber.ReadInt32(); //time + aGrabber.ReadInt32(); //crc + aGrabber.ReadInt32(); //compressed size + aGrabber.ReadInt32(); //size + sal_Int16 nPathLen = aGrabber.ReadInt16(); + sal_Int16 nExtraLen = aGrabber.ReadInt16(); rEntry.nOffset = aGrabber.getPosition() + nPathLen + nExtraLen; // FIXME64: need to read 64bit LOC @@ -754,8 +752,8 @@ sal_Int32 ZipFile::readCEN() throw(IOException, ZipException, RuntimeException) { // this method is called in constructor only, no need for mutex - sal_Int32 nCenLen, nCenPos = -1, nCenOff, nEndPos, nLocPos; - sal_uInt16 nCount, nTotal; + sal_Int32 nCenPos = -1, nEndPos, nLocPos; + sal_uInt16 nCount; try { @@ -763,9 +761,9 @@ sal_Int32 ZipFile::readCEN() if (nEndPos == -1) return -1; aGrabber.seek(nEndPos + ENDTOT); - aGrabber.ReadUInt16( nTotal ); - aGrabber.ReadInt32( nCenLen ); - aGrabber.ReadInt32( nCenOff ); + sal_uInt16 nTotal = aGrabber.ReadUInt16(); + sal_Int32 nCenLen = aGrabber.ReadInt32(); + sal_Int32 nCenOff = aGrabber.ReadInt32(); if ( nTotal * CENHDR > nCenLen ) throw ZipException("invalid END header (bad entry count)" ); @@ -791,39 +789,36 @@ sal_Int32 ZipFile::readCEN() MemoryByteGrabber aMemGrabber ( aCENBuffer ); ZipEntry aEntry; - sal_Int32 nTestSig; sal_Int16 nCommentLen; for (nCount = 0 ; nCount < nTotal; nCount++) { - aMemGrabber.ReadInt32( nTestSig ); + sal_Int32 nTestSig = aMemGrabber.ReadInt32(); if ( nTestSig != CENSIG ) throw ZipException("Invalid CEN header (bad signature)" ); aMemGrabber.skipBytes ( 2 ); - aMemGrabber.ReadInt16( aEntry.nVersion ); + aEntry.nVersion = aMemGrabber.ReadInt16(); if ( ( aEntry.nVersion & 1 ) == 1 ) throw ZipException("Invalid CEN header (encrypted entry)" ); - aMemGrabber.ReadInt16( aEntry.nFlag ); - aMemGrabber.ReadInt16( aEntry.nMethod ); + aEntry.nFlag = aMemGrabber.ReadInt16(); + aEntry.nMethod = aMemGrabber.ReadInt16(); if ( aEntry.nMethod != STORED && aEntry.nMethod != DEFLATED) throw ZipException("Invalid CEN header (bad compression method)" ); - aMemGrabber.ReadInt32( aEntry.nTime ); - aMemGrabber.ReadInt32( aEntry.nCrc ); + aEntry.nTime = aMemGrabber.ReadInt32(); + aEntry.nCrc = aMemGrabber.ReadInt32(); - sal_uInt32 nCompressedSize, nSize, nOffset; - - aMemGrabber.ReadUInt32( nCompressedSize ); - aMemGrabber.ReadUInt32( nSize ); - aMemGrabber.ReadInt16( aEntry.nPathLen ); - aMemGrabber.ReadInt16( aEntry.nExtraLen ); - aMemGrabber.ReadInt16( nCommentLen ); + sal_uInt32 nCompressedSize = aMemGrabber.ReadUInt32(); + sal_uInt32 nSize = aMemGrabber.ReadUInt32(); + aEntry.nPathLen = aMemGrabber.ReadInt16(); + aEntry.nExtraLen = aMemGrabber.ReadInt16(); + nCommentLen = aMemGrabber.ReadInt16(); aMemGrabber.skipBytes ( 8 ); - aMemGrabber.ReadUInt32( nOffset ); + sal_uInt32 nOffset = aMemGrabber.ReadUInt32(); // FIXME64: need to read the 64bit header instead if ( nSize == 0xffffffff || @@ -905,22 +900,20 @@ sal_Int32 ZipFile::recover() ZipEntry aEntry; MemoryByteGrabber aMemGrabber ( Sequence< sal_Int8 >( ((sal_Int8*)(&(pBuffer[nPos+4]))), 26 ) ); - aMemGrabber.ReadInt16( aEntry.nVersion ); + aEntry.nVersion = aMemGrabber.ReadInt16(); if ( ( aEntry.nVersion & 1 ) != 1 ) { - aMemGrabber.ReadInt16( aEntry.nFlag ); - aMemGrabber.ReadInt16( aEntry.nMethod ); + aEntry.nFlag = aMemGrabber.ReadInt16(); + aEntry.nMethod = aMemGrabber.ReadInt16(); if ( aEntry.nMethod == STORED || aEntry.nMethod == DEFLATED ) { - sal_uInt32 nCompressedSize, nSize; - - aMemGrabber.ReadInt32( aEntry.nTime ); - aMemGrabber.ReadInt32( aEntry.nCrc ); - aMemGrabber.ReadUInt32( nCompressedSize ); - aMemGrabber.ReadUInt32( nSize ); - aMemGrabber.ReadInt16( aEntry.nPathLen ); - aMemGrabber.ReadInt16( aEntry.nExtraLen ); + aEntry.nTime = aMemGrabber.ReadInt32(); + aEntry.nCrc = aMemGrabber.ReadInt32(); + sal_uInt32 nCompressedSize = aMemGrabber.ReadUInt32(); + sal_uInt32 nSize = aMemGrabber.ReadUInt32(); + aEntry.nPathLen = aMemGrabber.ReadInt16(); + aEntry.nExtraLen = aMemGrabber.ReadInt16(); // FIXME64: need to read the 64bit header instead if ( nSize == 0xffffffff || @@ -974,13 +967,11 @@ sal_Int32 ZipFile::recover() } else if (pBuffer[nPos] == 'P' && pBuffer[nPos+1] == 'K' && pBuffer[nPos+2] == 7 && pBuffer[nPos+3] == 8 ) { - sal_Int32 nCRC32; - sal_uInt32 nCompressedSize32, nSize32; sal_Int64 nCompressedSize, nSize; MemoryByteGrabber aMemGrabber ( Sequence< sal_Int8 >( ((sal_Int8*)(&(pBuffer[nPos+4]))), 12 ) ); - aMemGrabber.ReadInt32( nCRC32 ); - aMemGrabber.ReadUInt32( nCompressedSize32 ); - aMemGrabber.ReadUInt32( nSize32 ); + sal_Int32 nCRC32 = aMemGrabber.ReadInt32(); + sal_uInt32 nCompressedSize32 = aMemGrabber.ReadUInt32(); + sal_uInt32 nSize32 = aMemGrabber.ReadUInt32(); // FIXME64: work to be done here ... nCompressedSize = nCompressedSize32; |