diff options
author | Noel <noelgrandin@gmail.com> | 2020-10-01 14:02:32 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-10-01 19:36:39 +0200 |
commit | 9bac19e37f5a432375d24e8f210bb58de9c31bd8 (patch) | |
tree | 5b48512eeef519279895381c90f0e247ee365628 /connectivity | |
parent | a2d3b5721fc723608cea13a78ce09f959d0b9b9f (diff) |
loplugin:reducevarscope in comphelper,connectivity
Change-Id: Ia70d4963fb892120cc8f79597b46a8fe67b540a9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103762
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/commontools/ParameterSubstitution.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/commontools/TSkipDeletedSet.cxx | 4 | ||||
-rw-r--r-- | connectivity/source/commontools/dbtools.cxx | 30 | ||||
-rw-r--r-- | connectivity/source/drivers/dbase/DTable.cxx | 6 | ||||
-rw-r--r-- | connectivity/source/drivers/hsqldb/HDriver.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/Reader.cxx | 3 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/ResultSet.cxx | 3 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/tools.cxx | 3 | ||||
-rw-r--r-- | connectivity/source/drivers/odbc/OResultSet.cxx | 4 |
9 files changed, 26 insertions, 31 deletions
diff --git a/connectivity/source/commontools/ParameterSubstitution.cxx b/connectivity/source/commontools/ParameterSubstitution.cxx index 3a58fed70b09..ca96cf331406 100644 --- a/connectivity/source/commontools/ParameterSubstitution.cxx +++ b/connectivity/source/commontools/ParameterSubstitution.cxx @@ -66,11 +66,11 @@ namespace connectivity { OSQLParser aParser( m_xContext ); OUString sErrorMessage; - OUString sNewSql; std::unique_ptr<OSQLParseNode> pNode = aParser.parseTree(sErrorMessage,_sText); if(pNode) { // special handling for parameters OSQLParseNode::substituteParameterNames(pNode.get()); + OUString sNewSql; pNode->parseNodeToStr( sNewSql, xConnection ); sRet = sNewSql; } diff --git a/connectivity/source/commontools/TSkipDeletedSet.cxx b/connectivity/source/commontools/TSkipDeletedSet.cxx index d3ae392f7a09..701bd743f6c0 100644 --- a/connectivity/source/commontools/TSkipDeletedSet.cxx +++ b/connectivity/source/commontools/TSkipDeletedSet.cxx @@ -171,7 +171,7 @@ bool OSkipDeletedSet::moveAbsolute(sal_Int32 _nPos,bool _bRetrieveData) { // bookmark isn't known yet // start at the last known position - sal_Int32 nCurPos = 0,nLastBookmark = 1; + sal_Int32 nCurPos = 0; if ( m_aBookmarksPositions.empty() ) { bDataFound = m_pHelper->move(IResultSetHelper::FIRST, 0, _bRetrieveData ); @@ -185,7 +185,7 @@ bool OSkipDeletedSet::moveAbsolute(sal_Int32 _nPos,bool _bRetrieveData) } // if ( m_aBookmarksPositions.empty() ) else { - nLastBookmark = (*m_aBookmarksPositions.rbegin())/*->first*/; + sal_Int32 nLastBookmark = *m_aBookmarksPositions.rbegin()/*->first*/; nCurPos = /*(**/m_aBookmarksPositions.size()/*->second*/; nNewPos = nNewPos - nCurPos; bDataFound = m_pHelper->move(IResultSetHelper::BOOKMARK, nLastBookmark, _bRetrieveData); diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index 7f2e418601e9..a94a99a6327c 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -917,7 +917,7 @@ Reference< XNumberFormatsSupplier> getNumberFormats( // ask the parent of the connection (should be a DatabaseAccess) Reference< XNumberFormatsSupplier> xReturn; Reference< XChild> xConnAsChild(_rxConn, UNO_QUERY); - OUString sPropFormatsSupplier( "NumberFormatsSupplier" ); + static const OUStringLiteral sPropFormatsSupplier( u"NumberFormatsSupplier" ); if (xConnAsChild.is()) { Reference< XPropertySet> xConnParentProps(xConnAsChild->getParent(), UNO_QUERY); @@ -952,20 +952,20 @@ try Property* pNewProps = aNewProperties.getArray(); - OUString sPropFormatsSupplier("FormatsSupplier"); - OUString sPropCurrencySymbol("CurrencySymbol"); - OUString sPropDecimals("Decimals"); - OUString sPropEffectiveMin("EffectiveMin"); - OUString sPropEffectiveMax("EffectiveMax"); - OUString sPropEffectiveDefault("EffectiveDefault"); - OUString sPropDefaultText("DefaultText"); - OUString sPropDefaultDate("DefaultDate"); - OUString sPropDefaultTime("DefaultTime"); - OUString sPropValueMin("ValueMin"); - OUString sPropValueMax("ValueMax"); - OUString sPropDecimalAccuracy("DecimalAccuracy"); - OUString sPropClassId("ClassId"); - OUString sFormattedServiceName( "com.sun.star.form.component.FormattedField" ); + static const OUStringLiteral sPropFormatsSupplier(u"FormatsSupplier"); + static const OUStringLiteral sPropCurrencySymbol(u"CurrencySymbol"); + static const OUStringLiteral sPropDecimals(u"Decimals"); + static const OUStringLiteral sPropEffectiveMin(u"EffectiveMin"); + static const OUStringLiteral sPropEffectiveMax(u"EffectiveMax"); + static const OUStringLiteral sPropEffectiveDefault(u"EffectiveDefault"); + static const OUStringLiteral sPropDefaultText(u"DefaultText"); + static const OUStringLiteral sPropDefaultDate(u"DefaultDate"); + static const OUStringLiteral sPropDefaultTime(u"DefaultTime"); + static const OUStringLiteral sPropValueMin(u"ValueMin"); + static const OUStringLiteral sPropValueMax(u"ValueMax"); + static const OUStringLiteral sPropDecimalAccuracy(u"DecimalAccuracy"); + static const OUStringLiteral sPropClassId(u"ClassId"); + static const OUStringLiteral sFormattedServiceName( u"com.sun.star.form.component.FormattedField" ); for (const Property& rOldProp : aOldProperties) { diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index 879a23f8a3f4..e9be4d578ed2 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -153,11 +153,10 @@ void lcl_CalDate(sal_Int32 _nJulianDate,sal_Int32 _nJulianTime,css::util::DateTi { if ( _nJulianDate ) { - sal_Int32 ialp; sal_Int32 ka = _nJulianDate; if ( _nJulianDate >= 2299161 ) { - ialp = static_cast<sal_Int32>( (static_cast<double>(_nJulianDate) - 1867216.25 ) / 36524.25 ); + sal_Int32 ialp = static_cast<sal_Int32>( (static_cast<double>(_nJulianDate) - 1867216.25 ) / 36524.25 ); ka = _nJulianDate + 1 + ialp - ( ialp >> 2 ); } sal_Int32 kb = ka + 1524; @@ -2137,7 +2136,6 @@ void ODbaseTable::alterColumn(sal_Int32 index, if(index < 0 || index >= m_xColumns->getCount()) throw IndexOutOfBoundsException(OUString::number(index),*this); - ODbaseTable* pNewTable = nullptr; try { OSL_ENSURE(descriptor.is(),"ODbaseTable::alterColumn: descriptor can not be null!"); @@ -2154,7 +2152,7 @@ void ODbaseTable::alterColumn(sal_Int32 index, OUString sTempName = createTempFile(); - pNewTable = new ODbaseTable(m_pTables,static_cast<ODbaseConnection*>(m_pConnection)); + ODbaseTable* pNewTable = new ODbaseTable(m_pTables,static_cast<ODbaseConnection*>(m_pConnection)); Reference<XPropertySet> xHoldTable = pNewTable; pNewTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(sTempName)); Reference<XAppend> xAppend(pNewTable->getColumns(),UNO_QUERY); diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx index 99ac4f21b508..6ff0f539407b 100644 --- a/connectivity/source/drivers/hsqldb/HDriver.cxx +++ b/connectivity/source/drivers/hsqldb/HDriver.cxx @@ -239,10 +239,10 @@ namespace connectivity ); aProperties.put( "SystemProperties", Sequence< NamedValue >( &aPermittedClasses, 1 ) ); - const OUString sProperties( "properties" ); OUString sMessage; try { + const OUString sProperties( "properties" ); if ( !bIsNewDatabase && xStorage->isStreamElement(sProperties) ) { Reference<XStream > xStream = xStorage->openStreamElement(sProperties,ElementModes::READ); diff --git a/connectivity/source/drivers/jdbc/Reader.cxx b/connectivity/source/drivers/jdbc/Reader.cxx index 8dd12157e3ee..85d02e87a3e3 100644 --- a/connectivity/source/drivers/jdbc/Reader.cxx +++ b/connectivity/source/drivers/jdbc/Reader.cxx @@ -129,7 +129,6 @@ sal_Int32 SAL_CALL java_io_Reader::readBytes( css::uno::Sequence< sal_Int8 >& aD sal_Int32 nCharsToRead = (nBytesToRead + 1)/2; - jint outChars(0); SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!"); { @@ -139,7 +138,7 @@ sal_Int32 SAL_CALL java_io_Reader::readBytes( css::uno::Sequence< sal_Int8 >& aD // Java-Call static jmethodID mID(nullptr); obtainMethodId_throwRuntime(t.pEnv, cMethodName,cSignature, mID); - outChars = t.pEnv->CallIntMethod( object, mID, pCharArray, 0, nCharsToRead ); + jint outChars = t.pEnv->CallIntMethod( object, mID, pCharArray, 0, nCharsToRead ); if ( !outChars ) { if(nBytesWritten==0) diff --git a/connectivity/source/drivers/jdbc/ResultSet.cxx b/connectivity/source/drivers/jdbc/ResultSet.cxx index 238e78702c61..0144ea5fd87b 100644 --- a/connectivity/source/drivers/jdbc/ResultSet.cxx +++ b/connectivity/source/drivers/jdbc/ResultSet.cxx @@ -288,7 +288,6 @@ Reference< XRef > SAL_CALL java_sql_ResultSet::getRef( sal_Int32 columnIndex ) Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Reference< css::container::XNameAccess >& typeMap ) { - jobject out(nullptr); Any aRet; SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!"); { @@ -307,7 +306,7 @@ Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Referen obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID); } - out = t.pEnv->CallObjectMethodA( object, mID, args); + jobject out = t.pEnv->CallObjectMethodA( object, mID, args); t.pEnv->DeleteLocalRef(static_cast<jstring>(args[1].l)); ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); // and clean up diff --git a/connectivity/source/drivers/jdbc/tools.cxx b/connectivity/source/drivers/jdbc/tools.cxx index 5021d653a889..4a4d5069ea18 100644 --- a/connectivity/source/drivers/jdbc/tools.cxx +++ b/connectivity/source/drivers/jdbc/tools.cxx @@ -37,7 +37,6 @@ using namespace ::com::sun::star::lang; void java_util_Properties::setProperty(const OUString& key, const OUString& value) { SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!"); - jobject out(nullptr); { jvalue args[2]; @@ -50,7 +49,7 @@ void java_util_Properties::setProperty(const OUString& key, const OUString& valu // Turn off Java-Call static jmethodID mID(nullptr); obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID); - out = t.pEnv->CallObjectMethod(object, mID, args[0].l,args[1].l); + jobject out = t.pEnv->CallObjectMethod(object, mID, args[0].l,args[1].l); ThrowSQLException(t.pEnv,nullptr); t.pEnv->DeleteLocalRef(static_cast<jstring>(args[1].l)); t.pEnv->DeleteLocalRef(static_cast<jstring>(args[0].l)); diff --git a/connectivity/source/drivers/odbc/OResultSet.cxx b/connectivity/source/drivers/odbc/OResultSet.cxx index 61e5caecfa77..8081e3d80192 100644 --- a/connectivity/source/drivers/odbc/OResultSet.cxx +++ b/connectivity/source/drivers/odbc/OResultSet.cxx @@ -104,10 +104,10 @@ OResultSet::OResultSet(SQLHANDLE _pStatementHandle ,OStatement_Base* pStmt) : catch(const Exception&) { // we don't want our result destroy here } - SQLULEN nCurType = 0; + try { - nCurType = getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_TYPE); + SQLULEN nCurType = getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_TYPE); SQLUINTEGER nValueLen = m_pStatement->getCursorProperties(nCurType,false); if( (nValueLen & SQL_CA2_SENSITIVITY_DELETIONS) != SQL_CA2_SENSITIVITY_DELETIONS || (nValueLen & SQL_CA2_CRC_EXACT) != SQL_CA2_CRC_EXACT) |