diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2014-12-08 19:36:22 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-12-09 03:24:35 +0000 |
commit | 54cbb57d4c3ccf1e1c8455ac413183edbdeb3416 (patch) | |
tree | 989caae10d27ec9907b298af288ad2a4ef175622 /connectivity | |
parent | 141469eb831c054d6f4b56fcaa50a03e52429f11 (diff) |
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@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'connectivity')
8 files changed, 10 insertions, 18 deletions
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index 19fc244f4ecf..8f102141c641 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 01f66a9aa859..65774cb0c676 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 d93fef878f16..d0d0ab24df06 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 d682ac31378e..f0b85913182e 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 43ee0c1b45e6..1c8b443e371d 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 50cea162a297..427931e2b2e8 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 3e3b17809e44..167965c14ae7 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 59cd828c2c5d..7faa7e37a790 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 |