[Libreoffice-commits] core.git: embeddedobj/source extensions/source

Michael Weghorn m.weghorn at posteo.de
Sun Dec 14 22:44:00 PST 2014


 embeddedobj/source/general/docholder.cxx         |    6 +++---
 extensions/source/bibliography/framectr.cxx      |    2 +-
 extensions/source/ole/unoconversionutilities.hxx |    2 +-
 extensions/source/scanner/sane.cxx               |    4 +++-
 extensions/source/scanner/sanedlg.cxx            |    2 +-
 extensions/source/update/check/updatecheck.cxx   |    5 ++---
 6 files changed, 11 insertions(+), 10 deletions(-)

New commits:
commit aba7f4c0a3527ce0cee6e18385cf69778052402d
Author: Michael Weghorn <m.weghorn at posteo.de>
Date:   Fri Dec 12 19:07:13 2014 +0100

    fdo#39440 reduce scope of local variables
    
    This addresses some cppcheck warnings.
    
    Change-Id: I026999d6e995185c42df6770a1a700094540d08a
    Reviewed-on: https://gerrit.libreoffice.org/13454
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/embeddedobj/source/general/docholder.cxx b/embeddedobj/source/general/docholder.cxx
index 9bb8581..b720f0e 100644
--- a/embeddedobj/source/general/docholder.cxx
+++ b/embeddedobj/source/general/docholder.cxx
@@ -695,11 +695,11 @@ bool DocumentHolder::ShowUI( const uno::Reference< ::com::sun::star::frame::XLay
         }
         catch( const uno::Exception& ){}
 
-        // make sure that lock state of LM is correct even if an exception is thrown in between
-        bool bUnlock = false;
-        bool bLock = false;
         if ( xOwnLM.is() && xDocAreaAcc.is() )
         {
+            // make sure that lock state of LM is correct even if an exception is thrown in between
+            bool bUnlock = false;
+            bool bLock = false;
             try
             {
                 // take over the control over the containers window
diff --git a/extensions/source/bibliography/framectr.cxx b/extensions/source/bibliography/framectr.cxx
index 8124063..ba2f7a8 100644
--- a/extensions/source/bibliography/framectr.cxx
+++ b/extensions/source/bibliography/framectr.cxx
@@ -323,7 +323,6 @@ throw (::com::sun::star::uno::RuntimeException, std::exception)
 {
     const CmdToInfoCache& rCmdCache = GetCommandToInfoCache();
 
-    bool                                    bGroupFound( false );
     frame::DispatchInformation                  aDispatchInfo;
     std::list< frame::DispatchInformation >     aDispatchInfoList;
 
@@ -332,6 +331,7 @@ throw (::com::sun::star::uno::RuntimeException, std::exception)
         ( nCommandGroup == frame::CommandGroup::DATA ) ||
         ( nCommandGroup == frame::CommandGroup::VIEW ))
     {
+        bool bGroupFound = false;
         CmdToInfoCache::const_iterator pIter = rCmdCache.begin();
         while ( pIter != rCmdCache.end() )
         {
diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx
index b263dbe..d0ab452 100644
--- a/extensions/source/ole/unoconversionutilities.hxx
+++ b/extensions/source/ole/unoconversionutilities.hxx
@@ -686,9 +686,9 @@ void UnoConversionUtilities<T>::anyToVariant(VARIANT* pVariant, const Any& rAny,
 template<class T>
 void UnoConversionUtilities<T>::anyToVariant(VARIANT* pVariant, const Any& rAny)
 {
-    bool bIllegal = false;
     try
     {
+        bool bIllegal = false;
         switch (rAny.getValueTypeClass())
         {
         case TypeClass_INTERFACE:
diff --git a/extensions/source/scanner/sane.cxx b/extensions/source/scanner/sane.cxx
index 84475d5..ccc597c 100644
--- a/extensions/source/scanner/sane.cxx
+++ b/extensions/source/scanner/sane.cxx
@@ -559,12 +559,13 @@ bool Sane::Start( BitmapTransporter& rBitmap )
 
     int nWidthMM    = 0;
     int nHeightMM   = 0;
-    double fTLx, fTLy, fBRx, fBRy, fResl = 0.0;
+    double fTLx, fTLy, fResl = 0.0;
     int nOption;
     if( ( nOption = GetOptionByName( "tl-x" ) ) != -1   &&
         GetOptionValue( nOption, fTLx, 0 )              &&
         GetOptionUnit( nOption ) == SANE_UNIT_MM )
     {
+        double fBRx;
         if( ( nOption = GetOptionByName( "br-x" ) ) != -1   &&
             GetOptionValue( nOption, fBRx, 0 )              &&
             GetOptionUnit( nOption ) == SANE_UNIT_MM )
@@ -576,6 +577,7 @@ bool Sane::Start( BitmapTransporter& rBitmap )
         GetOptionValue( nOption, fTLy, 0 )              &&
         GetOptionUnit( nOption ) == SANE_UNIT_MM )
     {
+        double fBRy;
         if( ( nOption = GetOptionByName( "br-y" ) ) != -1   &&
             GetOptionValue( nOption, fBRy, 0 )              &&
             GetOptionUnit( nOption ) == SANE_UNIT_MM )
diff --git a/extensions/source/scanner/sanedlg.cxx b/extensions/source/scanner/sanedlg.cxx
index bc7ee8e..9a4e50c 100644
--- a/extensions/source/scanner/sanedlg.cxx
+++ b/extensions/source/scanner/sanedlg.cxx
@@ -761,11 +761,11 @@ IMPL_LINK( SaneDlg, ModifyHdl, Edit*, pEdit )
         }
         else if( pEdit == mpVectorBox )
         {
-            char pBuf[256];
             mnCurrentElement = mpVectorBox->GetValue()-1;
             double fValue;
             if( mrSane.GetOptionValue( mnCurrentOption, fValue, mnCurrentElement ))
             {
+                char pBuf[256];
                 sprintf( pBuf, "%g", fValue );
                 OUString aValue( pBuf, strlen(pBuf), osl_getThreadTextEncoding() );
                 mpNumericEdit->SetText( aValue );
diff --git a/extensions/source/update/check/updatecheck.cxx b/extensions/source/update/check/updatecheck.cxx
index 0ec3546..bf7b6a5 100644
--- a/extensions/source/update/check/updatecheck.cxx
+++ b/extensions/source/update/check/updatecheck.cxx
@@ -465,7 +465,6 @@ UpdateCheckThread::run()
 {
     osl_setThreadName("UpdateCheckThread");
 
-    bool bExtensionsChecked = false;
     TimeValue systime;
     TimeValue nExtCheckTime;
     osl_getSystemTime( &nExtCheckTime );
@@ -477,6 +476,7 @@ UpdateCheckThread::run()
     aResult = m_aCondition.wait(&tv);
 
     try {
+        bool bExtensionsChecked = false;
 
         while( schedule() )
         {
@@ -569,9 +569,8 @@ UpdateCheckThread::run()
 void SAL_CALL
 ManualUpdateCheckThread::run()
 {
-    bool bExtensionsChecked = false;
-
     try {
+        bool bExtensionsChecked = false;
         runCheck( bExtensionsChecked );
         m_aCondition.reset();
     }


More information about the Libreoffice-commits mailing list