diff options
author | Noel Grandin <noel@peralex.com> | 2016-07-21 14:23:23 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-08-16 06:30:09 +0000 |
commit | 127f70d66ac32b7a4ec818adaf1bdccb71865ee5 (patch) | |
tree | a020d2002c2eea81484297421f0fbe3ee84c2db0 /connectivity | |
parent | ce95e39f8e952159844e9dc04a1df402bb103634 (diff) |
new loplugin to check for static OUStrings
that are better declared as OUStringLiteral
Change-Id: Ifb5d9a12bb31a68641940bec16971a8181a46567
Reviewed-on: https://gerrit.libreoffice.org/27377
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'connectivity')
7 files changed, 30 insertions, 37 deletions
diff --git a/connectivity/source/drivers/calc/CTable.cxx b/connectivity/source/drivers/calc/CTable.cxx index cc3f874b107b..cae94275f944 100644 --- a/connectivity/source/drivers/calc/CTable.cxx +++ b/connectivity/source/drivers/calc/CTable.cxx @@ -460,10 +460,7 @@ void OCalcTable::fillColumns() switch ( eType ) { case DataType::VARCHAR: - { - static const OUString s_sType("VARCHAR"); - aTypeName = s_sType; - } + aTypeName = "VARCHAR"; break; case DataType::DECIMAL: aTypeName = "DECIMAL"; diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx index 33cc2c5cc866..ad843c4ae012 100644 --- a/connectivity/source/drivers/firebird/Connection.cxx +++ b/connectivity/source/drivers/firebird/Connection.cxx @@ -75,7 +75,11 @@ using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::uno; -const OUString Connection::our_sDBLocation( "firebird.fdb" ); +/** + * Location within the .odb that an embedded .fdb will be stored. + * Only relevant for embedded dbs. + */ +static const OUStringLiteral our_sDBLocation( "firebird.fdb" ); Connection::Connection(FirebirdDriver* _pDriver) : Connection_BASE(m_aMutex) diff --git a/connectivity/source/drivers/firebird/Connection.hxx b/connectivity/source/drivers/firebird/Connection.hxx index b1dd5f307e55..aad55e9fb94d 100644 --- a/connectivity/source/drivers/firebird/Connection.hxx +++ b/connectivity/source/drivers/firebird/Connection.hxx @@ -71,12 +71,6 @@ namespace connectivity { friend class connectivity::OSubComponent<Connection, Connection_BASE>; - /** - * Location within the .odb that an embedded .fdb will be stored. - * Only relevant for embedded dbs. - */ - static const OUString our_sDBLocation; - ::osl::Mutex m_aMutex; TTypeInfoVector m_aTypeInfo; // vector containing an entry diff --git a/connectivity/source/drivers/firebird/Driver.cxx b/connectivity/source/drivers/firebird/Driver.cxx index 6b87abe714e0..ab83b502fd6f 100644 --- a/connectivity/source/drivers/firebird/Driver.cxx +++ b/connectivity/source/drivers/firebird/Driver.cxx @@ -57,10 +57,12 @@ namespace connectivity } } -// Static const member variables -const OUString FirebirdDriver::our_sFirebirdTmpVar("FIREBIRD_TMP"); -const OUString FirebirdDriver::our_sFirebirdLockVar("FIREBIRD_LOCK"); -const OUString FirebirdDriver::our_sFirebirdMsgVar("FIREBIRD_MSG"); +// Static const variables +namespace { +const char our_sFirebirdTmpVar[] = "FIREBIRD_TMP"; +const char our_sFirebirdLockVar[] = "FIREBIRD_LOCK"; +const char our_sFirebirdMsgVar[] = "FIREBIRD_MSG"; +}; FirebirdDriver::FirebirdDriver(const css::uno::Reference< css::uno::XComponentContext >& _rxContext) : ODriver_BASE(m_aMutex) @@ -79,10 +81,10 @@ FirebirdDriver::FirebirdDriver(const css::uno::Reference< css::uno::XComponentCo // we can create directories for firebird at will. // Overrides firebird's default of /tmp or c:\temp - osl_setEnvironment(our_sFirebirdTmpVar.pData, m_firebirdTMPDirectory.GetFileName().pData); + osl_setEnvironment(OUString(our_sFirebirdTmpVar).pData, m_firebirdTMPDirectory.GetFileName().pData); // Overrides firebird's default of /tmp/firebird or c:\temp\firebird - osl_setEnvironment(our_sFirebirdLockVar.pData, m_firebirdLockDirectory.GetFileName().pData); + osl_setEnvironment(OUString(our_sFirebirdLockVar).pData, m_firebirdLockDirectory.GetFileName().pData); #ifndef SYSTEM_FIREBIRD // Overrides firebird's hardcoded default of /usr/local/firebird on *nix, @@ -91,7 +93,7 @@ FirebirdDriver::FirebirdDriver(const css::uno::Reference< css::uno::XComponentCo ::rtl::Bootstrap::expandMacros(sMsgURL); OUString sMsgPath; ::osl::FileBase::getSystemPathFromFileURL(sMsgURL, sMsgPath); - osl_setEnvironment(our_sFirebirdMsgVar.pData, sMsgPath.pData); + osl_setEnvironment(OUString(our_sFirebirdMsgVar).pData, sMsgPath.pData); #endif } @@ -113,11 +115,11 @@ void FirebirdDriver::disposing() } m_xConnections.clear(); - osl_clearEnvironment(our_sFirebirdTmpVar.pData); - osl_clearEnvironment(our_sFirebirdLockVar.pData); + osl_clearEnvironment(OUString(our_sFirebirdTmpVar).pData); + osl_clearEnvironment(OUString(our_sFirebirdLockVar).pData); #ifndef SYSTEM_FIREBIRD - osl_clearEnvironment(our_sFirebirdMsgVar.pData); + osl_clearEnvironment(OUString(our_sFirebirdMsgVar).pData); #endif OSL_VERIFY(fb_shutdown(0, 1)); diff --git a/connectivity/source/drivers/firebird/Driver.hxx b/connectivity/source/drivers/firebird/Driver.hxx index 64eeb53839c6..e3ce787755b0 100644 --- a/connectivity/source/drivers/firebird/Driver.hxx +++ b/connectivity/source/drivers/firebird/Driver.hxx @@ -47,10 +47,6 @@ namespace connectivity class FirebirdDriver : public ODriver_BASE { private: - static const ::rtl::OUString our_sFirebirdTmpVar; - static const ::rtl::OUString our_sFirebirdLockVar; - static const ::rtl::OUString our_sFirebirdMsgVar; - css::uno::Reference<css::uno::XComponentContext> m_aContext; ::utl::TempFile m_firebirdTMPDirectory; ::utl::TempFile m_firebirdLockDirectory; diff --git a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx index 4b6ab474c5a8..e76c2370474d 100644 --- a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx +++ b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx @@ -431,14 +431,14 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTablePrivileges( { // here we know that the count of column doesn't match ::std::map<sal_Int32,sal_Int32> aColumnMatching; - static const OUString sPrivs[] = { - OUString("TABLE_CAT"), - OUString("TABLE_SCHEM"), - OUString("TABLE_NAME"), - OUString("GRANTOR"), - OUString("GRANTEE"), - OUString("PRIVILEGE"), - OUString("IS_GRANTABLE") + static const OUStringLiteral sPrivs[] = { + OUStringLiteral("TABLE_CAT"), + OUStringLiteral("TABLE_SCHEM"), + OUStringLiteral("TABLE_NAME"), + OUStringLiteral("GRANTOR"), + OUStringLiteral("GRANTEE"), + OUStringLiteral("PRIVILEGE"), + OUStringLiteral("IS_GRANTABLE") }; OUString sColumnName; diff --git a/connectivity/source/drivers/mork/MDatabaseMetaData.cxx b/connectivity/source/drivers/mork/MDatabaseMetaData.cxx index db1b65a6e22f..44a4c0cf934b 100644 --- a/connectivity/source/drivers/mork/MDatabaseMetaData.cxx +++ b/connectivity/source/drivers/mork/MDatabaseMetaData.cxx @@ -837,10 +837,10 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException, std::exception) { // there exists no possibility to get table types so we have to check - static const OUString sTableTypes[] = + static const OUStringLiteral sTableTypes[] = { - OUString("TABLE"), - OUString("VIEW") + OUStringLiteral("TABLE"), + OUStringLiteral("VIEW") // Currently we only support a 'TABLE' and 'VIEW' nothing more complex // OUString("SYSTEM TABLE"), @@ -858,7 +858,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLE { ODatabaseMetaDataResultSet::ORow aRow; aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator(sTableType)); + aRow.push_back(new ORowSetValueDecorator(OUString(sTableType))); // bound row aRows.push_back(aRow); } |