From a3d0091d185f39eddabf4d372ebe0ac3061dbb89 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 23 Dec 2020 13:16:31 +0100 Subject: New loplugin:stringliteralvar See the comment at the top of compilerplugins/clang/stringliteralvar.cxx for details. (Turned some affected variables in included files into inline variables, to avoid GCC warnings about unused variables.) Change-Id: Ie77219e6adfdaaceaa8b4e590b08971f2f04c83a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108239 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- connectivity/source/commontools/conncleanup.cxx | 2 +- connectivity/source/commontools/dbtools2.cxx | 2 +- connectivity/source/cpool/ZConnectionPool.cxx | 2 +- connectivity/source/drivers/evoab2/NResultSetMetaData.cxx | 2 +- connectivity/source/drivers/file/FDatabaseMetaData.cxx | 2 +- connectivity/source/drivers/firebird/Driver.cxx | 6 +++--- connectivity/source/drivers/jdbc/JConnection.cxx | 3 ++- connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx | 5 +++-- connectivity/source/parse/sqliterator.cxx | 2 +- 9 files changed, 14 insertions(+), 12 deletions(-) (limited to 'connectivity') diff --git a/connectivity/source/commontools/conncleanup.cxx b/connectivity/source/commontools/conncleanup.cxx index c33cc7289a65..f1d80581ff5a 100644 --- a/connectivity/source/commontools/conncleanup.cxx +++ b/connectivity/source/commontools/conncleanup.cxx @@ -35,7 +35,7 @@ namespace dbtools using namespace css::sdbc; using namespace css::lang; - const char ACTIVE_CONNECTION_PROPERTY_NAME[] = "ActiveConnection"; + const OUStringLiteral ACTIVE_CONNECTION_PROPERTY_NAME = u"ActiveConnection"; OAutoConnectionDisposer::OAutoConnectionDisposer(const Reference< XRowSet >& _rxRowSet, const Reference< XConnection >& _rxConnection) :m_xRowSet( _rxRowSet ) diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx index 59f7dd50136e..db6e81a7400a 100644 --- a/connectivity/source/commontools/dbtools2.cxx +++ b/connectivity/source/commontools/dbtools2.cxx @@ -1014,7 +1014,7 @@ bool isAggregateColumn( const Reference< XPropertySet > &_xColumn ) { bool bAgg(false); - static const char sAgg[] = "AggregateFunction"; + static const OUStringLiteral sAgg = u"AggregateFunction"; if ( _xColumn->getPropertySetInfo()->hasPropertyByName(sAgg) ) _xColumn->getPropertyValue(sAgg) >>= bAgg; diff --git a/connectivity/source/cpool/ZConnectionPool.cxx b/connectivity/source/cpool/ZConnectionPool.cxx index 7d05b6e0236b..c0b034814deb 100644 --- a/connectivity/source/cpool/ZConnectionPool.cxx +++ b/connectivity/source/cpool/ZConnectionPool.cxx @@ -41,7 +41,7 @@ void SAL_CALL OPoolTimer::onShot() m_pPool->invalidatePooledConnections(); } -const char TIMEOUT_NODENAME[] = "Timeout"; +const OUStringLiteral TIMEOUT_NODENAME = u"Timeout"; OConnectionPool::OConnectionPool(const Reference< XDriver >& _xDriver, const Reference< XInterface >& _xDriverNode, diff --git a/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx b/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx index 4982cc455665..4c9446348681 100644 --- a/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx +++ b/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx @@ -40,7 +40,7 @@ OEvoabResultSetMetaData::~OEvoabResultSetMetaData() void OEvoabResultSetMetaData::setEvoabFields(const ::rtl::Reference &xColumns) { - static const char aName[] = "Name"; + static const OUStringLiteral aName = u"Name"; for (const auto& rxColumn : *xColumns) { diff --git a/connectivity/source/drivers/file/FDatabaseMetaData.cxx b/connectivity/source/drivers/file/FDatabaseMetaData.cxx index c965367dab0e..6a247ee8f41e 100644 --- a/connectivity/source/drivers/file/FDatabaseMetaData.cxx +++ b/connectivity/source/drivers/file/FDatabaseMetaData.cxx @@ -165,7 +165,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( // check if any type is given // when no types are given then we have to return all tables e.g. TABLE - static const char aTable[] = "TABLE"; + static const OUStringLiteral aTable = u"TABLE"; bool bTableFound = true; sal_Int32 nLength = types.getLength(); diff --git a/connectivity/source/drivers/firebird/Driver.cxx b/connectivity/source/drivers/firebird/Driver.cxx index 3ad9576c11fb..04c65ba06860 100644 --- a/connectivity/source/drivers/firebird/Driver.cxx +++ b/connectivity/source/drivers/firebird/Driver.cxx @@ -45,9 +45,9 @@ using namespace connectivity::firebird; // Static const variables namespace { -const char our_sFirebirdTmpVar[] = "FIREBIRD_TMP"; -const char our_sFirebirdLockVar[] = "FIREBIRD_LOCK"; -const char our_sFirebirdMsgVar[] = "FIREBIRD_MSG"; +const OUStringLiteral our_sFirebirdTmpVar = u"FIREBIRD_TMP"; +const OUStringLiteral our_sFirebirdLockVar = u"FIREBIRD_LOCK"; +const OUStringLiteral our_sFirebirdMsgVar = u"FIREBIRD_MSG"; #ifdef MACOSX const char our_sFirebirdLibVar[] = "LIBREOFFICE_FIREBIRD_LIB"; #endif diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx index 1d33f2941316..cf0b549b11aa 100644 --- a/connectivity/source/drivers/jdbc/JConnection.cxx +++ b/connectivity/source/drivers/jdbc/JConnection.cxx @@ -699,7 +699,8 @@ void java_sql_Connection::loadDriverFromProperties( const OUString& _sDriverClas OUString java_sql_Connection::impl_getJavaDriverClassPath_nothrow(const OUString& _sDriverClass) { - static const char s_sNodeName[] = "org.openoffice.Office.DataAccess/JDBC/DriverClassPaths"; + static const OUStringLiteral s_sNodeName + = u"org.openoffice.Office.DataAccess/JDBC/DriverClassPaths"; ::utl::OConfigurationTreeRoot aNamesRoot = ::utl::OConfigurationTreeRoot::createWithComponentContext( m_pDriver->getContext(), s_sNodeName, -1, ::utl::OConfigurationTreeRoot::CM_READONLY); OUString sURL; diff --git a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx index a47758f31a5d..28cb14faa981 100644 --- a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx +++ b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx @@ -1090,8 +1090,9 @@ void ODatabaseMetaDataResultSet::openSpecialColumns(bool _bRowVer,const Any& cat // E.g. psqlodbc up to at least version 09.01.0100 segfaults if (table.empty()) { - const char errMsg[] = "ODBC: Trying to get special columns of empty table name"; - const char SQLState[] = "HY009"; + static const OUStringLiteral errMsg + = u"ODBC: Trying to get special columns of empty table name"; + static const OUStringLiteral SQLState = u"HY009"; throw SQLException( errMsg, *this, SQLState, -1, Any() ); } diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index d7d7512b7acd..9f860327757c 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -264,7 +264,7 @@ namespace { OUString sComposedName; - static const char s_sWildcard[] = "%" ; + static const OUStringLiteral s_sWildcard = u"%" ; // we want all catalogues, all schemas, all tables Sequence< OUString > sTableTypes(3); -- cgit