package/source/zipapi/ZipFile.cxx              |    8 ++++----
 package/source/zippackage/ZipPackage.cxx       |   13 +++++++------
 package/source/zippackage/ZipPackageStream.cxx |    2 +-
 3 files changed, 12 insertions(+), 11 deletions(-)

New commits:
commit 29fefd93b8f8c7bd9fff1d5da2b7bb3fcfa4a89f
Author:     Noel <noelgran...@gmail.com>
AuthorDate: Thu Nov 5 11:26:01 2020 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Nov 5 17:19:42 2020 +0100

    loplugin:reducevarscope in package
    
    Change-Id: If35738232ceb0442d57b9e9b37a850e0920e61b2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105335
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/package/source/zipapi/ZipFile.cxx 
b/package/source/zipapi/ZipFile.cxx
index e82298de458b..2a76c7b750ed 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -830,11 +830,11 @@ void ZipFile::readLOC( ZipEntry &rEntry )
 sal_Int32 ZipFile::findEND()
 {
     // this method is called in constructor only, no need for mutex
-    sal_Int32 nLength, nPos, nEnd;
+    sal_Int32 nPos, nEnd;
     Sequence < sal_Int8 > aBuffer;
     try
     {
-        nLength = static_cast <sal_Int32 > (aGrabber.getLength());
+        sal_Int32 nLength = static_cast <sal_Int32 > (aGrabber.getLength());
         if (nLength < ENDHDR)
             return -1;
         nPos = nLength - ENDHDR - ZIP_MAXNAMELEN;
@@ -874,12 +874,12 @@ sal_Int32 ZipFile::findEND()
 sal_Int32 ZipFile::readCEN()
 {
     // this method is called in constructor only, no need for mutex
-    sal_Int32 nCenPos = -1, nEndPos, nLocPos;
+    sal_Int32 nCenPos = -1, nLocPos;
     sal_uInt16 nCount;
 
     try
     {
-        nEndPos = findEND();
+        sal_Int32 nEndPos = findEND();
         if (nEndPos == -1)
             return -1;
         aGrabber.seek(nEndPos + ENDTOT);
diff --git a/package/source/zippackage/ZipPackage.cxx 
b/package/source/zippackage/ZipPackage.cxx
index bdb5c25a8bf0..34a55fcea869 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -176,9 +176,8 @@ void ZipPackage::parseManifest()
     const OUString sMeta ("META-INF");
     if ( m_xRootFolder->hasByName( sMeta ) )
     {
-        const OUString sManifest ("manifest.xml");
-
         try {
+            const OUString sManifest ("manifest.xml");
             uno::Reference< XUnoTunnel > xTunnel;
             Any aAny = m_xRootFolder->getByName( sMeta );
             aAny >>= xTunnel;
@@ -457,8 +456,8 @@ void ZipPackage::parseContentType()
     if ( m_nFormat != embed::StorageFormats::OFOPXML )
         return;
 
-    const OUString aContentTypes("[Content_Types].xml");
     try {
+        const OUString aContentTypes("[Content_Types].xml");
         // the content type must exist in OFOPXML format!
         if ( !m_xRootFolder->hasByName( aContentTypes ) )
             throw io::IOException(THROW_WHERE "Wrong format!" );
@@ -899,8 +898,8 @@ Any SAL_CALL ZipPackage::getByHierarchicalName( const 
OUString& aName )
 
 sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const OUString& aName )
 {
-    OUString sTemp, sDirName;
-    sal_Int32 nOldIndex, nStreamIndex;
+    OUString sTemp;
+    sal_Int32 nOldIndex;
     FolderHash::iterator aIter;
 
     sal_Int32 nIndex = aName.getLength();
@@ -911,6 +910,8 @@ sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const 
OUString& aName )
 
     try
     {
+        OUString sDirName;
+        sal_Int32 nStreamIndex;
         nStreamIndex = aName.lastIndexOf ( '/' );
         bool bFolder = nStreamIndex == nIndex-1;
         if ( nStreamIndex != -1 )
@@ -1105,13 +1106,13 @@ void ZipPackage::WriteContentTypes( ZipOutputStream& 
aZipOut, const vector< uno:
     sal_Int32 nOverSeqLength = 0;
     for (const auto& rMan : aManList)
     {
-        OUString aPath;
         OUString aType;
         OSL_ENSURE( rMan[PKG_MNFST_MEDIATYPE].Name == "MediaType" && 
rMan[PKG_MNFST_FULLPATH].Name == "FullPath",
                     "The mediatype sequence format is wrong!" );
         rMan[PKG_MNFST_MEDIATYPE].Value >>= aType;
         if ( !aType.isEmpty() )
         {
+            OUString aPath;
             // only nonempty type makes sense here
             rMan[PKG_MNFST_FULLPATH].Value >>= aPath;
             //FIXME: For now we have no way of differentiating defaults from 
others.
diff --git a/package/source/zippackage/ZipPackageStream.cxx 
b/package/source/zippackage/ZipPackageStream.cxx
index 71f9ad9f2ba1..1c055dcc2905 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -373,7 +373,6 @@ bool ZipPackageStream::ParsePackageRawStream()
     bool bOk = false;
 
     ::rtl::Reference< BaseEncryptionData > xTempEncrData;
-    sal_Int32 nMagHackSize = 0;
     Sequence < sal_Int8 > aHeader ( 4 );
 
     try
@@ -395,6 +394,7 @@ bool ZipPackageStream::ParsePackageRawStream()
                 sal_Int32 nChecksumAlgorithm = 0;
                 sal_Int32 nDerivedKeySize = 0;
                 sal_Int32 nStartKeyGenID = 0;
+                sal_Int32 nMagHackSize = 0;
                 if ( ZipFile::StaticFillData( xTempEncrData, nEncAlgorithm, 
nChecksumAlgorithm, nDerivedKeySize, nStartKeyGenID, nMagHackSize, aMediaType, 
GetOwnSeekStream() ) )
                 {
                     // We'll want to skip the data we've just read, so 
calculate how much we just read
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to