[Libreoffice-commits] core.git: cli_ure/source connectivity/source

Michael Weghorn m.weghorn at posteo.de
Mon Dec 8 19:25:09 PST 2014


 cli_ure/source/uno_bridge/cli_data.cxx                  |    4 +---
 connectivity/source/drivers/dbase/DTable.cxx            |    6 ++----
 connectivity/source/drivers/dbase/dindexnode.cxx        |    3 +--
 connectivity/source/drivers/file/FStatement.cxx         |    3 +--
 connectivity/source/drivers/firebird/Util.cxx           |    2 +-
 connectivity/source/drivers/hsqldb/HDriver.cxx          |    3 +--
 connectivity/source/drivers/jdbc/PreparedStatement.cxx  |    3 ++-
 connectivity/source/drivers/macab/MacabRecords.cxx      |    3 +--
 connectivity/source/drivers/odbc/OPreparedStatement.cxx |    5 +----
 9 files changed, 11 insertions(+), 21 deletions(-)

New commits:
commit 54cbb57d4c3ccf1e1c8455ac413183edbdeb3416
Author: Michael Weghorn <m.weghorn at posteo.de>
Date:   Mon Dec 8 19:36:22 2014 +0100

    fdo#39440 reduce scope of local variables
    
    This addresses some cppcheck warnings.
    
    Change-Id: Ib35eb591534c3f23adc3cb7b7fa9696dc5cbeabf
    Reviewed-on: https://gerrit.libreoffice.org/13383
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/cli_ure/source/uno_bridge/cli_data.cxx b/cli_ure/source/uno_bridge/cli_data.cxx
index c1671d7..3efd7a4 100644
--- a/cli_ure/source/uno_bridge/cli_data.cxx
+++ b/cli_ure/source/uno_bridge/cli_data.cxx
@@ -1058,12 +1058,10 @@ void Bridge::map_to_uno(void * uno_data, System::Object^ cli_data,
             sal_Int32 nPos = 0;
             try
             {
-                typelib_TypeDescriptionReference * member_type= NULL;
-
                 OUString usUnoException("com.sun.star.uno.Exception");
                 for (; nPos < nMembers; ++nPos)
                 {
-                    member_type= comp_td->ppTypeRefs[nPos];
+                    typelib_TypeDescriptionReference * member_type= comp_td->ppTypeRefs[nPos];
                     System::Object^ val= nullptr;
                     if (cli_data != nullptr)
                     {
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index 19fc244..8f10214 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -2551,12 +2551,11 @@ void ODbaseTable::copyData(ODbaseTable* _pNewTable,sal_Int32 _nPos)
         (aRow->get())[nPos]->setBound(false);
 
 
-    bool bOk = true;
     sal_Int32 nCurPos;
     OValueRefVector::Vector::iterator aIter;
     for(sal_uInt32 nRowPos = 0; nRowPos < m_aHeader.db_anz;++nRowPos)
     {
-        bOk = seekRow( IResultSetHelper::BOOKMARK, nRowPos+1, nCurPos );
+        bool bOk = seekRow( IResultSetHelper::BOOKMARK, nRowPos+1, nCurPos );
         if ( bOk )
         {
             bOk = fetchRow( aRow, *m_aColumns, true, true);
@@ -2698,8 +2697,6 @@ End:
 
 bool ODbaseTable::ReadMemo(sal_Size nBlockNo, ORowSetValue& aVariable)
 {
-    bool bIsText = true;
-
     m_pMemoStream->Seek(nBlockNo * m_aMemoHeader.db_size);
     switch (m_aMemoHeader.db_typ)
     {
@@ -2732,6 +2729,7 @@ bool ODbaseTable::ReadMemo(sal_Size nBlockNo, ORowSetValue& aVariable)
         case MemoFoxPro:
         case MemodBaseIV: // dBase IV-Memofield with length
         {
+            bool bIsText = true;
             char sHeader[4];
             m_pMemoStream->Read(sHeader,4);
             // Foxpro stores text and binary data
diff --git a/connectivity/source/drivers/dbase/dindexnode.cxx b/connectivity/source/drivers/dbase/dindexnode.cxx
index 01f66a9..65774cb 100644
--- a/connectivity/source/drivers/dbase/dindexnode.cxx
+++ b/connectivity/source/drivers/dbase/dindexnode.cxx
@@ -194,7 +194,6 @@ bool ONDXPage::Insert(ONDXNode& rNode, sal_uInt32 nRowsLeft)
     bool bAppend = nRowsLeft > 0;
     if (IsFull())
     {
-        bool bResult = true;
         ONDXNode aSplitNode;
         if (bAppend)
             aSplitNode = rNode;
@@ -204,7 +203,7 @@ bool ONDXPage::Insert(ONDXNode& rNode, sal_uInt32 nRowsLeft)
             aSplitNode = (*this)[nCount-1];
             if(rNode.GetKey() <= aSplitNode.GetKey())
             {
-
+                bool bResult = true;
                 // this practically reduces the number of nodes by 1
                 if (IsLeaf() && this == rIndex.m_aCurLeaf)
                 {
diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx
index d93fef8..d0d0ab2 100644
--- a/connectivity/source/drivers/file/FStatement.cxx
+++ b/connectivity/source/drivers/file/FStatement.cxx
@@ -574,11 +574,10 @@ void OStatement_Base::GetAssignValues()
         OSL_ENSURE(pInsertAtomCommalist != NULL,"OResultSet: pInsertAtomCommalist darf nicht NULL sein!");
         OSL_ENSURE(pInsertAtomCommalist->count() > 0,"OResultSet: pInsertAtomCommalist <= 0");
 
-        OSQLParseNode * pRow_Value_Const;
         sal_Int32 nIndex=0;
         for (sal_uInt32 i = 0; i < pInsertAtomCommalist->count(); i++)
         {
-            pRow_Value_Const = pInsertAtomCommalist->getChild(i); // row_value_constructor
+            OSQLParseNode * pRow_Value_Const = pInsertAtomCommalist->getChild(i); // row_value_constructor
             OSL_ENSURE(pRow_Value_Const != NULL,"OResultSet: pRow_Value_Const darf nicht NULL sein!");
             if(SQL_ISRULE(pRow_Value_Const,parameter))
             {
diff --git a/connectivity/source/drivers/firebird/Util.cxx b/connectivity/source/drivers/firebird/Util.cxx
index d682ac3..f0b8591 100644
--- a/connectivity/source/drivers/firebird/Util.cxx
+++ b/connectivity/source/drivers/firebird/Util.cxx
@@ -28,12 +28,12 @@ OUString firebird::StatusVectorToString(const ISC_STATUS_ARRAY& rStatusVector,
                                     const OUString& rCause)
 {
     OUStringBuffer buf;
-    char msg[512]; // Size is based on suggestion in docs.
     const ISC_STATUS* pStatus = (const ISC_STATUS*) &rStatusVector;
 
     buf.appendAscii("firebird_sdbc error:");
     try
     {
+        char msg[512]; // Size is based on suggestion in docs.
         while(fb_interpret(msg, sizeof(msg), &pStatus))
         {
             // TODO: verify encoding
diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx
index 43ee0c1..1c8b443 100644
--- a/connectivity/source/drivers/hsqldb/HDriver.cxx
+++ b/connectivity/source/drivers/hsqldb/HDriver.cxx
@@ -354,12 +354,11 @@ namespace connectivity
 
                 if ( xOrig.is() )
                 {
-                    OMetaConnection* pMetaConnection = NULL;
                     // now we have to set the URL to get the correct answer for metadata()->getURL()
                     Reference< XUnoTunnel> xTunnel(xOrig,UNO_QUERY);
                     if ( xTunnel.is() )
                     {
-                        pMetaConnection = reinterpret_cast<OMetaConnection*>(xTunnel->getSomething( OMetaConnection::getUnoTunnelImplementationId() ));
+                        OMetaConnection* pMetaConnection = reinterpret_cast<OMetaConnection*>(xTunnel->getSomething( OMetaConnection::getUnoTunnelImplementationId() ));
                         if ( pMetaConnection )
                             pMetaConnection->setURL(url);
                     }
diff --git a/connectivity/source/drivers/jdbc/PreparedStatement.cxx b/connectivity/source/drivers/jdbc/PreparedStatement.cxx
index 50cea16..427931e 100644
--- a/connectivity/source/drivers/jdbc/PreparedStatement.cxx
+++ b/connectivity/source/drivers/jdbc/PreparedStatement.cxx
@@ -336,12 +336,13 @@ void SAL_CALL java_sql_PreparedStatement::setObjectWithInfo( sal_Int32 parameter
         obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
         {
             jobject obj = NULL;
-            double nTemp = 0.0;
             switch(targetSqlType)
             {
                 case DataType::DECIMAL:
                 case DataType::NUMERIC:
                     {
+                        double nTemp = 0.0;
+
                         boost::scoped_ptr<java_math_BigDecimal> pBigDecimal;
                         if ( x >>= nTemp)
                         {
diff --git a/connectivity/source/drivers/macab/MacabRecords.cxx b/connectivity/source/drivers/macab/MacabRecords.cxx
index 3e3b178..167965c 100644
--- a/connectivity/source/drivers/macab/MacabRecords.cxx
+++ b/connectivity/source/drivers/macab/MacabRecords.cxx
@@ -979,13 +979,12 @@ void MacabRecords::insertPropertyIntoMacabRecord(const ABPropertyType _propertyT
                  */
                 sal_Int32 arrLength = (sal_Int32) CFArrayGetCount( (CFArrayRef) _propertyValue);
                 sal_Int32 i;
-                const void *arrValue;
                 OUString newPropertyName;
 
                 /* Going through each element... */
                 for(i = 0; i < arrLength; i++)
                 {
-                    arrValue = CFArrayGetValueAtIndex( (CFArrayRef) _propertyValue, i);
+                    const void *arrValue = CFArrayGetValueAtIndex( (CFArrayRef) _propertyValue, i);
                     newPropertyName = _propertyName + OUString::number(i);
                     insertPropertyIntoMacabRecord(_abrecord, _header, newPropertyName, arrValue);
                     CFRelease(arrValue);
diff --git a/connectivity/source/drivers/odbc/OPreparedStatement.cxx b/connectivity/source/drivers/odbc/OPreparedStatement.cxx
index 59cd828..7faa7e3 100644
--- a/connectivity/source/drivers/odbc/OPreparedStatement.cxx
+++ b/connectivity/source/drivers/odbc/OPreparedStatement.cxx
@@ -158,9 +158,6 @@ sal_Bool SAL_CALL OPreparedStatement::execute(  ) throw(SQLException, RuntimeExc
     ::osl::MutexGuard aGuard( m_aMutex );
     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
 
-
-    bool needData = false;
-
     // Reset warnings
 
     clearWarnings ();
@@ -178,7 +175,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute(  ) throw(SQLException, RuntimeExc
         SQLRETURN nReturn = N3SQLExecute(m_aStatementHandle);
 
         OTools::ThrowException(m_pConnection,nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
-        needData = nReturn == SQL_NEED_DATA;
+        bool needData = nReturn == SQL_NEED_DATA;
 
         // Now loop while more data is needed (i.e. a data-at-
         // execution parameter was given).  For each parameter


More information about the Libreoffice-commits mailing list