From ccb2a1f650bc505f8a4f1abebf8ce4f9396562a8 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 16 Oct 2018 15:23:12 +0200 Subject: clang-tidy readability-redundant-smartptr-get redundant get() call on smart pointer Change-Id: Icb5a03bbc15e79a30d3d135a507d22914d15c2bd Reviewed-on: https://gerrit.libreoffice.org/61837 Tested-by: Jenkins Reviewed-by: Noel Grandin --- connectivity/source/commontools/paramwrapper.cxx | 2 +- connectivity/source/drivers/hsqldb/HDriver.cxx | 2 +- connectivity/source/drivers/jdbc/JConnection.cxx | 2 +- .../drivers/mysqlc/mysqlc_preparedstatement.cxx | 34 +++++++++------------- connectivity/source/drivers/odbc/OConnection.cxx | 2 +- .../source/drivers/postgresql/pq_connection.cxx | 2 +- connectivity/source/parse/sqliterator.cxx | 2 +- connectivity/source/parse/sqlnode.cxx | 2 +- 8 files changed, 21 insertions(+), 27 deletions(-) (limited to 'connectivity') diff --git a/connectivity/source/commontools/paramwrapper.cxx b/connectivity/source/commontools/paramwrapper.cxx index 38dbf9075333..08a89a539a32 100644 --- a/connectivity/source/commontools/paramwrapper.cxx +++ b/connectivity/source/commontools/paramwrapper.cxx @@ -150,7 +150,7 @@ namespace param ::cppu::IPropertyArrayHelper& ParameterWrapper::getInfoHelper() { - if ( !m_pInfoHelper.get() ) + if (!m_pInfoHelper) { Sequence< Property > aProperties; try diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx index 9f3ae07c3910..fc928b7325fa 100644 --- a/connectivity/source/drivers/hsqldb/HDriver.cxx +++ b/connectivity/source/drivers/hsqldb/HDriver.cxx @@ -259,7 +259,7 @@ namespace connectivity if ( xStream.is() ) { std::unique_ptr pStream( ::utl::UcbStreamHelper::CreateStream(xStream) ); - if ( pStream.get() ) + if (pStream) { OString sLine; OString sVersionString; diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx index bfaef457d35e..3e365c74478f 100644 --- a/connectivity/source/drivers/jdbc/JConnection.cxx +++ b/connectivity/source/drivers/jdbc/JConnection.cxx @@ -666,7 +666,7 @@ void java_sql_Connection::loadDriverFromProperties( const OUString& _sDriverClas ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); } - if ( pDrvClass.get() ) + if (pDrvClass) { LocalRef< jobject > driverObject( t.env() ); driverObject.set( pDrvClass->newInstanceObject() ); diff --git a/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx b/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx index b4a2844ce6f4..05204fe652a0 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx @@ -108,7 +108,7 @@ Reference SAL_CALL OPreparedStatement::getMetaData() { MYSQL_RES* pRes = mysql_stmt_result_metadata(m_pStmt); // TODO warning or error if no meta data. - m_xMetaData = new OResultSetMetaData(*m_xConnection.get(), pRes); + m_xMetaData = new OResultSetMetaData(*m_xConnection, pRes); } return m_xMetaData; } @@ -135,19 +135,17 @@ sal_Bool SAL_CALL OPreparedStatement::execute() if (!m_binds.empty() && mysql_stmt_bind_param(m_pStmt, m_binds.data())) { - MYSQL* pMysql = m_xConnection.get()->getMysqlConnection(); + MYSQL* pMysql = m_xConnection->getMysqlConnection(); mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt), mysql_errno(pMysql), - *this, - m_xConnection.get()->getConnectionEncoding()); + *this, m_xConnection->getConnectionEncoding()); } int nFail = mysql_stmt_execute(m_pStmt); if (nFail != 0) { - MYSQL* pMysql = m_xConnection.get()->getMysqlConnection(); + MYSQL* pMysql = m_xConnection->getMysqlConnection(); mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt), mysql_errno(pMysql), - *this, - m_xConnection.get()->getConnectionEncoding()); + *this, m_xConnection->getConnectionEncoding()); } return !nFail; @@ -160,20 +158,18 @@ sal_Int32 SAL_CALL OPreparedStatement::executeUpdate() if (!m_binds.empty() && mysql_stmt_bind_param(m_pStmt, m_binds.data())) { - MYSQL* pMysql = m_xConnection.get()->getMysqlConnection(); + MYSQL* pMysql = m_xConnection->getMysqlConnection(); mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt), mysql_errno(pMysql), - *this, - m_xConnection.get()->getConnectionEncoding()); + *this, m_xConnection->getConnectionEncoding()); } int nFail = mysql_stmt_execute(m_pStmt); if (nFail != 0) { - MYSQL* pMysql = m_xConnection.get()->getMysqlConnection(); + MYSQL* pMysql = m_xConnection->getMysqlConnection(); mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt), mysql_errno(pMysql), - *this, - m_xConnection.get()->getConnectionEncoding()); + *this, m_xConnection->getConnectionEncoding()); } sal_Int32 affectedRows = mysql_stmt_affected_rows(m_pStmt); @@ -210,24 +206,22 @@ Reference SAL_CALL OPreparedStatement::executeQuery() if (!m_binds.empty() && mysql_stmt_bind_param(m_pStmt, m_binds.data())) { - MYSQL* pMysql = m_xConnection.get()->getMysqlConnection(); + MYSQL* pMysql = m_xConnection->getMysqlConnection(); mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt), mysql_errno(pMysql), - *this, - m_xConnection.get()->getConnectionEncoding()); + *this, m_xConnection->getConnectionEncoding()); } int nFail = mysql_stmt_execute(m_pStmt); if (nFail != 0) { - MYSQL* pMysql = m_xConnection.get()->getMysqlConnection(); + MYSQL* pMysql = m_xConnection->getMysqlConnection(); mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt), mysql_errno(pMysql), - *this, - m_xConnection.get()->getConnectionEncoding()); + *this, m_xConnection->getConnectionEncoding()); } Reference xResultSet; - xResultSet = new OPreparedResultSet(*m_xConnection.get(), this, m_pStmt); + xResultSet = new OPreparedResultSet(*m_xConnection, this, m_pStmt); return xResultSet; } diff --git a/connectivity/source/drivers/odbc/OConnection.cxx b/connectivity/source/drivers/odbc/OConnection.cxx index 7d7a741f93c5..7a767ccdbe7c 100644 --- a/connectivity/source/drivers/odbc/OConnection.cxx +++ b/connectivity/source/drivers/odbc/OConnection.cxx @@ -78,7 +78,7 @@ OConnection::~OConnection() oslGenericFunction OConnection::getOdbcFunction(ODBC3SQLFunctionId _nIndex) const { - OSL_ENSURE(m_xDriver.get(),"OConnection::getOdbcFunction: m_xDriver is null!"); + OSL_ENSURE(m_xDriver, "OConnection::getOdbcFunction: m_xDriver is null!"); return m_xDriver->getOdbcFunction(_nIndex); } diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx b/connectivity/source/drivers/postgresql/pq_connection.cxx index 172c6fc5f130..0e196d302e6d 100644 --- a/connectivity/source/drivers/postgresql/pq_connection.cxx +++ b/connectivity/source/drivers/postgresql/pq_connection.cxx @@ -521,7 +521,7 @@ void Connection::initialize( const Sequence< Any >& aArguments ) { char *err; std::shared_ptr oOpts(PQconninfoParse(o.getStr(), &err), PQconninfoFree); - if ( oOpts.get() == nullptr ) + if (oOpts == nullptr) { OUString errorMessage; if ( err != nullptr) diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index dcca0fc9db4a..e29c8d394557 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -330,7 +330,7 @@ void OSQLParseTreeIterator::impl_getQueryParameterColumns( const OSQLTable& _rQu OUString sError; std::unique_ptr< OSQLParseNode > pSubQueryNode( const_cast< OSQLParser& >( m_rParser ).parseTree( sError, sSubQueryCommand ) ); - if ( !pSubQueryNode.get() ) + if (!pSubQueryNode) break; OSQLParseTreeIterator aSubQueryIterator( *this, m_rParser, pSubQueryNode.get() ); diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 683ac9e3b3c2..7d9ca005c071 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -679,7 +679,7 @@ bool OSQLParseNode::impl_parseTableNameNodeToString_throw( OUStringBuffer& rStri { OUString sError; std::unique_ptr< OSQLParseNode > pSubQueryNode( rParam.pParser->parseTree( sError, sCommand ) ); - if ( pSubQueryNode.get() ) + if (pSubQueryNode) { // parse the sub-select to SDBC level, too OUStringBuffer sSubSelect; -- cgit