[Libreoffice-commits] core.git: basctl/source basic/qa basic/source

Noel (via logerrit) logerrit at kemper.freedesktop.org
Thu Oct 1 14:13:04 UTC 2020


 basctl/source/basicide/localizationmgr.cxx |    6 ++----
 basic/qa/cppunit/basictest.cxx             |    2 +-
 basic/source/classes/image.cxx             |   10 +++++-----
 basic/source/runtime/methods.cxx           |    3 +--
 basic/source/runtime/runtime.cxx           |    7 +++----
 basic/source/uno/scriptcont.cxx            |    2 +-
 6 files changed, 13 insertions(+), 17 deletions(-)

New commits:
commit 38786f1df9ed8324a44c9f2afacb245744b54ebc
Author:     Noel <noelgrandin at gmail.com>
AuthorDate: Thu Oct 1 14:01:16 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Oct 1 16:12:20 2020 +0200

    loplugin:reducevarscope in basctl,basic
    
    Change-Id: I32595921bf5ed26699bced3637302692c407d624
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103760
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/basctl/source/basicide/localizationmgr.cxx b/basctl/source/basicide/localizationmgr.cxx
index 3a57c8de672d..45c6239bc5c7 100644
--- a/basctl/source/basicide/localizationmgr.cxx
+++ b/basctl/source/basicide/localizationmgr.cxx
@@ -302,10 +302,9 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
                         for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
                         {
                             const Locale& rLocale = pLocales[ i ];
-                            OUString aResStr;
                             try
                             {
-                                aResStr = xStringResourceManager->resolveStringForLocale
+                                OUString aResStr = xStringResourceManager->resolveStringForLocale
                                     ( aPureSourceIdStr, rLocale );
                                 xStringResourceManager->removeIdForLocale( aPureSourceIdStr, rLocale );
                                 xStringResourceManager->setStringForLocale( aPureIdStr, aResStr, rLocale );
@@ -515,10 +514,9 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
                             {
                                 const Locale& rLocale = pLocales[ iLocale ];
 
-                                OUString aResStr;
                                 try
                                 {
-                                    aResStr = xStringResourceManager->resolveStringForLocale
+                                    OUString aResStr = xStringResourceManager->resolveStringForLocale
                                         ( aPureSourceIdStr, rLocale );
                                     xStringResourceManager->removeIdForLocale( aPureSourceIdStr, rLocale );
                                     xStringResourceManager->setStringForLocale( aPureIdStr, aResStr, rLocale );
diff --git a/basic/qa/cppunit/basictest.cxx b/basic/qa/cppunit/basictest.cxx
index 4122885ba10c..f1e169ab8acc 100644
--- a/basic/qa/cppunit/basictest.cxx
+++ b/basic/qa/cppunit/basictest.cxx
@@ -48,11 +48,11 @@ void MacroSnippet::LoadSourceFromFile( const OUString& sMacroFileURL )
     if(aFile.open(osl_File_OpenFlag_Read) == osl::FileBase::E_None)
     {
         sal_uInt64 size;
-        sal_uInt64 size_read;
         if(aFile.getSize(size) == osl::FileBase::E_None)
         {
             void* buffer = calloc(1, size+1);
             CPPUNIT_ASSERT(buffer);
+            sal_uInt64 size_read;
             if(aFile.read( buffer, size, size_read) == osl::FileBase::E_None)
             {
                 if(size == size_read)
diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx
index eb127e755f1f..6ce3b8894ca9 100644
--- a/basic/source/classes/image.cxx
+++ b/basic/source/classes/image.cxx
@@ -117,15 +117,15 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion )
     // Read Master-Record
     r.ReadUInt16( nSign ).ReadUInt32( nLen ).ReadUInt16( nCount );
     sal_uInt64 nLast = r.Tell() + nLen;
-    sal_uInt32 nCharSet;               // System charset
-    sal_uInt32 lDimBase;
-    sal_uInt16 nReserved1;
-    sal_uInt32 nReserved2;
-    sal_uInt32 nReserved3;
     bool bBadVer = false;
     if( nSign == static_cast<sal_uInt16>( FileOffset::Module ) )
     {
+        sal_uInt32 nCharSet;               // System charset
+        sal_uInt32 lDimBase;
         sal_uInt16 nTmpFlags;
+        sal_uInt16 nReserved1;
+        sal_uInt32 nReserved2;
+        sal_uInt32 nReserved3;
         r.ReadUInt32( nVersion ).ReadUInt32( nCharSet ).ReadUInt32( lDimBase )
          .ReadUInt16( nTmpFlags ).ReadUInt16( nReserved1 ).ReadUInt32( nReserved2 ).ReadUInt32( nReserved3 );
         nFlags = static_cast<SbiImageFlags>(nTmpFlags);
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 78dcbf5097d6..3e8f8d23cd42 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -4107,8 +4107,6 @@ void SbRtl_StrConv(StarBASIC *, SbxArray & rPar, bool)
     OUString aOldStr = rPar.Get32(1)->GetOUString();
     sal_Int32 nConversion = rPar.Get32(2)->GetLong();
 
-    LanguageType nLanguage = LANGUAGE_SYSTEM;
-
     sal_Int32 nOldLen = aOldStr.getLength();
     if( nOldLen == 0 )
     {
@@ -4153,6 +4151,7 @@ void SbRtl_StrConv(StarBASIC *, SbxArray & rPar, bool)
         uno::Reference< uno::XComponentContext > xContext = getProcessComponentContext();
         ::utl::TransliterationWrapper aTransliterationWrapper( xContext, nType );
         uno::Sequence<sal_Int32> aOffsets;
+        LanguageType nLanguage = LANGUAGE_SYSTEM;
         aTransliterationWrapper.loadModuleIfNeeded( nLanguage );
         aNewStr = aTransliterationWrapper.transliterate( aOldStr, nLanguage, 0, nOldLen, &aOffsets );
     }
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 89fc75f31e8e..498c71628dba 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -784,7 +784,7 @@ bool SbiRuntime::Step()
         }
 
         SbiOpcode eOp = static_cast<SbiOpcode>( *pCode++ );
-        sal_uInt32 nOp1, nOp2;
+        sal_uInt32 nOp1;
         if (eOp <= SbiOpcode::SbOP0_END)
         {
             (this->*( aStep0[ int(eOp) ] ) )();
@@ -798,7 +798,7 @@ bool SbiRuntime::Step()
         else if (eOp >= SbiOpcode::SbOP2_START && eOp <= SbiOpcode::SbOP2_END)
         {
             nOp1 = *pCode++; nOp1 |= *pCode++ << 8; nOp1 |= *pCode++ << 16; nOp1 |= *pCode++ << 24;
-            nOp2 = *pCode++; nOp2 |= *pCode++ << 8; nOp2 |= *pCode++ << 16; nOp2 |= *pCode++ << 24;
+            sal_uInt32 nOp2 = *pCode++; nOp2 |= *pCode++ << 8; nOp2 |= *pCode++ << 16; nOp2 |= *pCode++ << 24;
             (this->*( aStep2[ int(eOp) - int(SbiOpcode::SbOP2_START) ] ) )( nOp1, nOp2 );
         }
         else
@@ -2430,7 +2430,6 @@ void SbiRuntime::StepARGV()
 void SbiRuntime::StepINPUT()
 {
     OUStringBuffer sin;
-    OUString s;
     char ch = 0;
     ErrCode err;
     // Skip whitespace
@@ -2482,7 +2481,7 @@ void SbiRuntime::StepINPUT()
     }
     if( !err )
     {
-        s = sin.makeStringAndClear();
+        OUString s = sin.makeStringAndClear();
         SbxVariableRef pVar = GetTOS();
         // try to fill the variable with a numeric value first,
         // then with a string value
diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx
index a5d7d02a1931..070d3cbbd74b 100644
--- a/basic/source/uno/scriptcont.cxx
+++ b/basic/source/uno/scriptcont.cxx
@@ -1026,9 +1026,9 @@ bool SfxScriptLibraryContainer::implLoadPasswordLibrary
                     if( bLoadSource || bVerifyPasswordOnly )
                     {
                         // Access encrypted source stream
-                        OUString aSourceStreamName( "source.xml" );
                         try
                         {
+                            OUString aSourceStreamName( "source.xml" );
                             uno::Reference< io::XStream > xSourceStream = xElementRootStorage->openEncryptedStreamElement(
                                                                     aSourceStreamName,
                                                                     embed::ElementModes::READ,


More information about the Libreoffice-commits mailing list