summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-28 10:33:09 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-29 08:51:48 +0200
commit1ffba0e356608fb6dbf568248e2a953b4d7fb5d6 (patch)
tree5da59640441292421f2137bc85ee7291daed137e /package
parentce9a41dc387966c74c1af92783a97565b5af3668 (diff)
loplugin:flatten check for throw in then clause
also make the plugin ignore the case where we have var decl's in the clause we want to flatten, which could lead to problematic extension of variable lifetime Change-Id: I3061f7104e8c6a460bf74f5eac325a516ec50c59 Reviewed-on: https://gerrit.libreoffice.org/42889 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'package')
-rw-r--r--package/source/zipapi/ZipFile.cxx12
-rw-r--r--package/source/zippackage/ZipPackageFolder.cxx47
2 files changed, 28 insertions, 31 deletions
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index 11bc362c6a48..bc978e9dcad1 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -917,11 +917,10 @@ sal_Int32 ZipFile::readCEN()
nOffset == 0xffffffff ||
nCompressedSize == 0xffffffff ) {
throw ZipException("PK64 zip file entry" );
- } else {
- aEntry.nCompressedSize = nCompressedSize;
- aEntry.nSize = nSize;
- aEntry.nOffset = nOffset;
}
+ aEntry.nCompressedSize = nCompressedSize;
+ aEntry.nSize = nSize;
+ aEntry.nOffset = nOffset;
aEntry.nOffset += nLocPos;
aEntry.nOffset *= -1;
@@ -1010,10 +1009,9 @@ void ZipFile::recover()
if ( nSize == 0xffffffff ||
nCompressedSize == 0xffffffff ) {
throw ZipException("PK64 zip file entry" );
- } else {
- aEntry.nCompressedSize = nCompressedSize;
- aEntry.nSize = nSize;
}
+ aEntry.nCompressedSize = nCompressedSize;
+ aEntry.nSize = nSize;
sal_Int32 nDescrLength =
( aEntry.nMethod == DEFLATED && ( aEntry.nFlag & 8 ) ) ? 16 : 0;
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index ed5e6d0d29ed..abee6bbdc562 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -169,33 +169,32 @@ void SAL_CALL ZipPackageFolder::insertByName( const OUString& aName, const uno::
{
if (hasByName(aName))
throw ElementExistException(THROW_WHERE );
- else
- {
- uno::Reference < XUnoTunnel > xRef;
- aElement >>= xRef;
- if ( !(aElement >>= xRef) )
- throw IllegalArgumentException(THROW_WHERE, uno::Reference< uno::XInterface >(), 0 );
-
- sal_Int64 nTest;
- ZipPackageEntry *pEntry;
- if ( ( nTest = xRef->getSomething ( ZipPackageFolder::static_getImplementationId() ) ) != 0 )
- {
- ZipPackageFolder *pFolder = reinterpret_cast < ZipPackageFolder * > ( nTest );
- pEntry = static_cast < ZipPackageEntry * > ( pFolder );
- }
- else if ( ( nTest = xRef->getSomething ( ZipPackageStream::static_getImplementationId() ) ) != 0 )
- {
- ZipPackageStream *pStream = reinterpret_cast < ZipPackageStream * > ( nTest );
- pEntry = static_cast < ZipPackageEntry * > ( pStream );
- }
- else
- throw IllegalArgumentException(THROW_WHERE, uno::Reference< uno::XInterface >(), 0 );
- if (pEntry->getName() != aName )
- pEntry->setName (aName);
- doInsertByName ( pEntry, true );
+ uno::Reference < XUnoTunnel > xRef;
+ aElement >>= xRef;
+ if ( !(aElement >>= xRef) )
+ throw IllegalArgumentException(THROW_WHERE, uno::Reference< uno::XInterface >(), 0 );
+
+ sal_Int64 nTest;
+ ZipPackageEntry *pEntry;
+ if ( ( nTest = xRef->getSomething ( ZipPackageFolder::static_getImplementationId() ) ) != 0 )
+ {
+ ZipPackageFolder *pFolder = reinterpret_cast < ZipPackageFolder * > ( nTest );
+ pEntry = static_cast < ZipPackageEntry * > ( pFolder );
+ }
+ else if ( ( nTest = xRef->getSomething ( ZipPackageStream::static_getImplementationId() ) ) != 0 )
+ {
+ ZipPackageStream *pStream = reinterpret_cast < ZipPackageStream * > ( nTest );
+ pEntry = static_cast < ZipPackageEntry * > ( pStream );
}
+ else
+ throw IllegalArgumentException(THROW_WHERE, uno::Reference< uno::XInterface >(), 0 );
+
+ if (pEntry->getName() != aName )
+ pEntry->setName (aName);
+ doInsertByName ( pEntry, true );
}
+
void SAL_CALL ZipPackageFolder::removeByName( const OUString& Name )
{
ContentHash::iterator aIter = maContents.find ( Name );