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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Sep 8 12:46:02 UTC 2018


 basic/source/basmgr/basmgr.cxx    |   14 ++++++--------
 basic/source/classes/sbunoobj.cxx |    5 ++---
 basic/source/runtime/runtime.cxx  |    9 ++++-----
 basic/source/sbx/sbxvar.cxx       |    2 +-
 4 files changed, 13 insertions(+), 17 deletions(-)

New commits:
commit b678dee6a856e3c0bd4e969db76f6a19970e5343
Author:     Jochen Nitschke <j.nitschke+logerrit at ok.de>
AuthorDate: Sat Sep 8 10:44:10 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Sep 8 14:45:42 2018 +0200

    cppcheck: variableScope in basic
    
    use a range based loop in one case
    
    Change-Id: I3d3acc35739634797e2b6e4d1cc2909b3fe33750
    Reviewed-on: https://gerrit.libreoffice.org/60188
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx
index 8318466c88f1..08e13d857eae 100644
--- a/basic/source/basmgr/basmgr.cxx
+++ b/basic/source/basmgr/basmgr.cxx
@@ -551,20 +551,18 @@ void BasicManager::SetLibraryContainerInfo( const LibraryContainerInfo& rInfo )
         xLibContainer->addContainerListener( xLibContainerListener );
 
         uno::Sequence< OUString > aScriptLibNames = xScriptCont->getElementNames();
-        const OUString* pScriptLibName = aScriptLibNames.getConstArray();
-        sal_Int32 i, nNameCount = aScriptLibNames.getLength();
 
-        if( nNameCount )
+        if( aScriptLibNames.hasElements() )
         {
-            for( i = 0 ; i < nNameCount ; ++i, ++pScriptLibName )
+            for(const auto& rScriptLibName : aScriptLibNames)
             {
-                uno::Any aLibAny = xScriptCont->getByName( *pScriptLibName );
+                uno::Any aLibAny = xScriptCont->getByName( rScriptLibName );
 
-                if ( *pScriptLibName == "Standard" || *pScriptLibName == "VBAProject")
-                    xScriptCont->loadLibrary( *pScriptLibName );
+                if ( rScriptLibName == "Standard" || rScriptLibName == "VBAProject")
+                    xScriptCont->loadLibrary( rScriptLibName );
 
                 BasMgrContainerListenerImpl::insertLibraryImpl
-                    ( xScriptCont, this, aLibAny, *pScriptLibName );
+                    ( xScriptCont, this, aLibAny, rScriptLibName );
             }
         }
         else
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 376bae1217b7..a2aebb7cd018 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -2150,7 +2150,6 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
                 sal_uInt32 nParamCount = pParams ? (static_cast<sal_uInt32>(pParams->Count()) - 1) : 0;
                 Sequence<Any> args;
                 bool bOutParams = false;
-                sal_uInt32 i;
 
                 if( !bInvocation && mxUnoAccess.is() )
                 {
@@ -2173,7 +2172,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
                         {
                             // Check types
                             bool bError = false;
-                            for( i = nParamCount ; i < nUnoParamCount ; i++ )
+                            for( sal_uInt32 i = nParamCount ; i < nUnoParamCount ; i++ )
                             {
                                 const ParamInfo& rInfo = pParamInfos[i];
                                 const Reference< XIdlClass >& rxClass = rInfo.aType;
@@ -2192,7 +2191,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
                     {
                         args.realloc( nAllocParamCount );
                         Any* pAnyArgs = args.getArray();
-                        for( i = 0 ; i < nParamCount ; i++ )
+                        for( sal_uInt32 i = 0 ; i < nParamCount ; i++ )
                         {
                             const ParamInfo& rInfo = pParamInfos[i];
                             const Reference< XIdlClass >& rxClass = rInfo.aType;
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 6ccf64f22dd1..eb94a927be03 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -4323,12 +4323,11 @@ void SbiRuntime::StepDCREATE_IMPL( sal_uInt32 nOp1, sal_uInt32 nOp2 )
         sal_Int32 nTotalSize = 0;
 
         // must be a one-dimensional array
-        sal_Int32 nLower, nUpper, nSize;
-        sal_Int32 i;
-        for( i = 0 ; i < nDims ; i++ )
+        sal_Int32 nLower, nUpper;
+        for( sal_Int32 i = 0 ; i < nDims ; ++i )
         {
             pArray->GetDim32( i+1, nLower, nUpper );
-            nSize = nUpper - nLower + 1;
+            sal_Int32 nSize = nUpper - nLower + 1;
             if( i == 0 )
             {
                 nTotalSize = nSize;
@@ -4341,7 +4340,7 @@ void SbiRuntime::StepDCREATE_IMPL( sal_uInt32 nOp1, sal_uInt32 nOp2 )
 
         // create objects and insert them into the array
         OUString aClass( pImg->GetString( static_cast<short>( nOp2 ) ) );
-        for( i = 0 ; i < nTotalSize ; i++ )
+        for( sal_Int32 i = 0 ; i < nTotalSize ; ++i )
         {
             SbxObject *pClassObj = SbxBase::CreateObject( aClass );
             if( !pClassObj )
diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx
index 3172cf5f686e..3759da581907 100644
--- a/basic/source/sbx/sbxvar.cxx
+++ b/basic/source/sbx/sbxvar.cxx
@@ -453,7 +453,6 @@ void SbxVariable::ClearComListener()
 
 bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer )
 {
-    sal_uInt16 nType;
     sal_uInt8 cMark;
     rStrm.ReadUChar( cMark );
     if( cMark == 0xFF )
@@ -470,6 +469,7 @@ bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer )
     }
     else
     {
+        sal_uInt16 nType;
         rStrm.SeekRel( -1 );
         rStrm.ReadUInt16( nType );
         maName = read_uInt16_lenPrefixed_uInt8s_ToOUString(rStrm,


More information about the Libreoffice-commits mailing list