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

Noel (via logerrit) logerrit at kemper.freedesktop.org
Sun Oct 4 12:06:50 UTC 2020


 toolkit/source/awt/vclxmenu.cxx                  |    2 +-
 toolkit/source/controls/formattedcontrol.cxx     |    2 +-
 tools/source/datetime/ttime.cxx                  |    8 +++-----
 tools/source/zcodec/zcodec.cxx                   |    3 ++-
 ucb/source/cacher/cachedcontentresultsetstub.cxx |    2 +-
 ucb/source/core/ucbstore.cxx                     |    7 ++-----
 ucb/source/ucp/file/filtask.cxx                  |   11 ++++++-----
 ucb/source/ucp/webdav-neon/webdavcontent.cxx     |    2 +-
 unotools/source/config/eventcfg.cxx              |    2 +-
 unotools/source/config/pathoptions.cxx           |    2 +-
 10 files changed, 19 insertions(+), 22 deletions(-)

New commits:
commit 27f1827afa11ba9c5d912614dc84dd308ecf8b5f
Author:     Noel <noelgrandin at gmail.com>
AuthorDate: Fri Oct 2 13:38:33 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Oct 4 14:06:14 2020 +0200

    loplugin:reducevarscope in toolkit..unotools
    
    Change-Id: I439b9f456ac0bfaa3eb9bf17472053bd4787e828
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103840
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx
index 93d154a92ed2..c6ebef12d18b 100644
--- a/toolkit/source/awt/vclxmenu.cxx
+++ b/toolkit/source/awt/vclxmenu.cxx
@@ -552,7 +552,7 @@ namespace
         const ::Size aCurSize = aImage.GetSizePixel();
         const sal_Int32 nCurWidth = aCurSize.Width();
         const sal_Int32 nCurHeight = aCurSize.Height();
-        const sal_Int32 nIdeal( 16 );
+        constexpr sal_Int32 nIdeal( 16 );
 
         if ( nCurWidth > 0 && nCurHeight > 0 )
         {
diff --git a/toolkit/source/controls/formattedcontrol.cxx b/toolkit/source/controls/formattedcontrol.cxx
index b438833557ad..d2acd9c2e17d 100644
--- a/toolkit/source/controls/formattedcontrol.cxx
+++ b/toolkit/source/controls/formattedcontrol.cxx
@@ -324,7 +324,6 @@ namespace toolkit
         if ( BASEPROPERTY_EFFECTIVE_DEFAULT == nPropId && rValue.hasValue() )
         {
             double dVal = 0;
-            OUString sVal;
             bool bStreamed = (rValue >>= dVal);
             if ( bStreamed )
             {
@@ -340,6 +339,7 @@ namespace toolkit
                 }
                 else
                 {
+                    OUString sVal;
                     bStreamed = (rValue >>= sVal);
                     if ( bStreamed )
                     {
diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx
index 7fbd361573de..356f1994ee4c 100644
--- a/tools/source/datetime/ttime.cxx
+++ b/tools/source/datetime/ttime.cxx
@@ -401,8 +401,6 @@ Time tools::Time::GetUTCOffset()
     sal_uInt64          nTicks = tools::Time::GetSystemTicks();
     time_t          nTime;
     tm              aTM;
-    sal_Int32           nLocalTime;
-    sal_Int32           nUTC;
     short           nTempTime;
 
     // determine value again if needed
@@ -413,17 +411,17 @@ Time tools::Time::GetUTCOffset()
     {
         nTime = time( nullptr );
         localtime_r( &nTime, &aTM );
-        nLocalTime = mktime( &aTM );
+        sal_Int32 nLocalTime = mktime( &aTM );
 #if defined(__sun)
         // Solaris gmtime_r() seems not to handle daylight saving time
         // flags correctly
         nUTC = nLocalTime + ( aTM.tm_isdst == 0 ? timezone : altzone );
 #elif defined( LINUX )
         // Linux mktime() seems not to handle tm_isdst correctly
-        nUTC = nLocalTime - aTM.tm_gmtoff;
+        sal_Int32 nUTC = nLocalTime - aTM.tm_gmtoff;
 #else
         gmtime_r( &nTime, &aTM );
-        nUTC = mktime( &aTM );
+        sal_Int32 nUTC = mktime( &aTM );
 #endif
         nCacheTicks = nTicks;
         nCacheSecOffset = (nLocalTime-nUTC) / 60;
diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index 525834681ef8..36386b9bb498 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -331,7 +331,7 @@ void ZCodec::InitDecompress(SvStream & inStream)
     auto pStream = static_cast<z_stream*>(mpsC_Stream);
     if ( mbStatus &&  mbGzLib )
     {
-        sal_uInt8 n1, n2, j, nMethod, nFlags;
+        sal_uInt8 j, nMethod, nFlags;
         for (int i : gz_magic)   // gz - magic number
         {
             inStream.ReadUChar( j );
@@ -349,6 +349,7 @@ void ZCodec::InitDecompress(SvStream & inStream)
         /* skip the extra field */
         if ( nFlags & GZ_EXTRA_FIELD )
         {
+            sal_uInt8 n1, n2;
             inStream.ReadUChar( n1 ).ReadUChar( n2 );
             inStream.SeekRel( n1 + ( n2 << 8 ) );
         }
diff --git a/ucb/source/cacher/cachedcontentresultsetstub.cxx b/ucb/source/cacher/cachedcontentresultsetstub.cxx
index cedd3d588dac..f570929e1ebf 100644
--- a/ucb/source/cacher/cachedcontentresultsetstub.cxx
+++ b/ucb/source/cacher/cachedcontentresultsetstub.cxx
@@ -226,9 +226,9 @@ FetchResult CachedContentResultSetStub::impl_fetchHelper(
     if( !nOldOriginal_Pos )
         bOldOriginal_AfterLast = m_xResultSetOrigin->isAfterLast();
     sal_Int32 nN = 1;
-    bool bValidNewPos = false;
     try
     {
+        bool bValidNewPos = false;
         try
         {
             /*if( nOldOriginal_Pos != nRowStartPosition )*/
diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx
index 3274c777fdc5..1ee882ff18d4 100644
--- a/ucb/source/core/ucbstore.cxx
+++ b/ucb/source/core/ucbstore.cxx
@@ -1553,15 +1553,12 @@ void SAL_CALL PersistentPropertySet::removeProperty( const OUString& Name )
 {
     osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
 
-    OUString aFullValuesName;
-    OUString aFullPropName;
-
     Reference< XHierarchicalNameAccess > xRootHierNameAccess(
                 m_pImpl->m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
     if ( xRootHierNameAccess.is() )
     {
-        aFullValuesName = getFullKey();
-        aFullPropName   = aFullValuesName + "/";
+        OUString aFullValuesName = getFullKey();
+        OUString aFullPropName   = aFullValuesName + "/";
         aFullPropName   += makeHierarchalNameSegment( Name );
 
         // Property in set?
diff --git a/ucb/source/ucp/file/filtask.cxx b/ucb/source/ucp/file/filtask.cxx
index 790dd3d7ba8c..4a8a36a35516 100644
--- a/ucb/source/ucp/file/filtask.cxx
+++ b/ucb/source/ucp/file/filtask.cxx
@@ -2274,7 +2274,7 @@ TaskManager::commit( const TaskManager::ContentMap::iterator& it,
     }
 
 
-    bool isDirectory,isFile,isVolume,isRemoveable,isRemote,isFloppy,isCompactDisc;
+    bool isDirectory;
 
     sal_Int64 dirSize = 0;
 
@@ -2283,6 +2283,7 @@ TaskManager::commit( const TaskManager::ContentMap::iterator& it,
 
     if( aFileStatus.isValid( osl_FileStatus_Mask_Type ) )
     {
+        bool isFile,isVolume;
         if( osl::FileStatus::Link == aFileStatus.getFileType() &&
             aFileStatus.isValid( osl_FileStatus_Mask_LinkTargetURL ) )
         {
@@ -2343,10 +2344,10 @@ TaskManager::commit( const TaskManager::ContentMap::iterator& it,
             aVolumeInfo.isValid( osl_VolumeInfo_Mask_Attributes ) )
         {
             // Retrieve the flags;
-            isRemote = aVolumeInfo.getRemoteFlag();
-            isRemoveable = aVolumeInfo.getRemoveableFlag();
-            isCompactDisc = aVolumeInfo.getCompactDiscFlag();
-            isFloppy = aVolumeInfo.getFloppyDiskFlag();
+            bool isRemote = aVolumeInfo.getRemoteFlag();
+            bool isRemoveable = aVolumeInfo.getRemoveableFlag();
+            bool isCompactDisc = aVolumeInfo.getCompactDiscFlag();
+            bool isFloppy = aVolumeInfo.getFloppyDiskFlag();
 
             it1 = properties.find( MyProperty( IsRemote ) );
             if( it1 != properties.end() )
diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
index fd78627c146f..a874390ceb33 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
@@ -3921,12 +3921,12 @@ void Content::getResourceOptions(
                     const std::unique_ptr< DAVResourceAccess > & rResAccess,
                     bool * networkAccessAllowed )
 {
-    OUString aRedirURL;
     OUString aTargetURL = rResAccess->getURL();
     DAVOptions aDAVOptions;
     // first check if in cache, if not, then send method to server
     if ( !aStaticDAVOptionsCache.getDAVOptions( aTargetURL, aDAVOptions ) )
     {
+        OUString aRedirURL;
         try
         {
             rResAccess->OPTIONS( aDAVOptions, xEnv );
diff --git a/unotools/source/config/eventcfg.cxx b/unotools/source/config/eventcfg.cxx
index b0e36fc62c4d..819a18576144 100644
--- a/unotools/source/config/eventcfg.cxx
+++ b/unotools/source/config/eventcfg.cxx
@@ -196,9 +196,9 @@ void GlobalEventConfig_Impl::initBindingInfo()
         lMacros[0] = aSetNode + rEventName + aCommandKey;
         SAL_INFO("unotools", "reading binding for: " << lMacros[0]);
         Sequence< Any > lValues = GetProperties( lMacros );
-        OUString sMacroURL;
         if( lValues.hasElements() )
         {
+            OUString sMacroURL;
             lValues[0] >>= sMacroURL;
             sal_Int32 startIndex = rEventName.indexOf('\'');
             sal_Int32 endIndex =  rEventName.lastIndexOf('\'');
diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx
index cb70189aa3dd..eb7d9244a897 100644
--- a/unotools/source/config/pathoptions.cxx
+++ b/unotools/source/config/pathoptions.cxx
@@ -218,7 +218,6 @@ const OUString& SvtPathOptions_Impl::GetPath( SvtPathOptions::Paths ePath )
     try
     {
         OUString    aPathValue;
-        OUString    aResult;
         sal_Int32   nHandle = m_aMapEnumToPropHandle[ static_cast<sal_Int32>(ePath) ];
 
         // Substitution is done by the service itself using the substitution service
@@ -233,6 +232,7 @@ const OUString& SvtPathOptions_Impl::GetPath( SvtPathOptions::Paths ePath )
           )
         {
             // These office paths have to be converted to system pates
+            OUString    aResult;
             osl::FileBase::getSystemPathFromFileURL( aPathValue, aResult );
             aPathValue = aResult;
         }


More information about the Libreoffice-commits mailing list