diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-10-15 01:57:12 +0300 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-10-17 09:53:42 +0200 |
commit | d51db77c8d87f210785a8a8c6dd875f7bacddb3c (patch) | |
tree | fd1ab208d49e85371fc9bb321539ce137bdaf719 /connectivity/source | |
parent | c8eaadb5d70f42723517bb028f363e37726be256 (diff) |
Remove some memset calls
Replace them with default initialization or calloc
Change-Id: I747f53c2ced2d0473fd5a5ede4f8520a0633dcc1
Reviewed-on: https://gerrit.libreoffice.org/80805
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'connectivity/source')
-rw-r--r-- | connectivity/source/drivers/dbase/DIndex.cxx | 1 | ||||
-rw-r--r-- | connectivity/source/drivers/dbase/DTable.cxx | 5 | ||||
-rw-r--r-- | connectivity/source/drivers/dbase/dindexnode.cxx | 6 | ||||
-rw-r--r-- | connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx | 7 | ||||
-rw-r--r-- | connectivity/source/drivers/odbc/OConnection.cxx | 6 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DIndex.hxx | 2 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DTable.hxx | 2 |
7 files changed, 9 insertions, 20 deletions
diff --git a/connectivity/source/drivers/dbase/DIndex.cxx b/connectivity/source/drivers/dbase/DIndex.cxx index 2626830cb4f7..5e4afbc94eb8 100644 --- a/connectivity/source/drivers/dbase/DIndex.cxx +++ b/connectivity/source/drivers/dbase/DIndex.cxx @@ -64,7 +64,6 @@ ODbaseIndex::ODbaseIndex(ODbaseTable* _pTable) , m_pTable(_pTable) , m_bUseCollector(false) { - memset(&m_aHeader, 0, sizeof(m_aHeader)); construct(); } diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index c6c6626a4965..ffd4eb2ab30f 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -437,7 +437,6 @@ ODbaseTable::ODbaseTable(sdbcx::OCollection* _pTables, ODbaseConnection* _pConne : ODbaseTable_BASE(_pTables,_pConnection) { // initialize the header - memset(&m_aHeader, 0, sizeof(m_aHeader)); m_aHeader.type = dBaseIII; m_eEncoding = getConnection()->getTextEncoding(); } @@ -454,7 +453,6 @@ ODbaseTable::ODbaseTable(sdbcx::OCollection* _pTables, ODbaseConnection* _pConne SchemaName, CatalogName) { - memset(&m_aHeader, 0, sizeof(m_aHeader)); m_eEncoding = getConnection()->getTextEncoding(); } @@ -1171,8 +1169,7 @@ bool ODbaseTable::CreateFile(const INetURLObject& aFile, bool& bCreateMemo) throw; } - char aBuffer[21]; // write buffer - memset(aBuffer,0,sizeof(aBuffer)); + char aBuffer[21] = {}; // write buffer m_pFileStream->Seek(0); (*m_pFileStream).WriteUChar( nDbaseType ); // dBase format diff --git a/connectivity/source/drivers/dbase/dindexnode.cxx b/connectivity/source/drivers/dbase/dindexnode.cxx index 10231a835ff9..251563e4d1d5 100644 --- a/connectivity/source/drivers/dbase/dindexnode.cxx +++ b/connectivity/source/drivers/dbase/dindexnode.cxx @@ -698,8 +698,7 @@ void ONDXNode::Write(SvStream &rStream, const ONDXPage& rPage) const } if (aKey.getValue().isNull()) { - sal_uInt8 buf[sizeof(double)]; - memset(&buf[0], 0, sizeof(double)); + sal_uInt8 buf[sizeof(double)] = {}; rStream.WriteBytes(&buf[0], sizeof(double)); } else @@ -890,8 +889,7 @@ SvStream& connectivity::dbase::WriteONDXPage(SvStream &rStream, const ONDXPage& rStream.SetStreamSize(nSize); rStream.Seek(rPage.GetPagePos() * DINDEX_PAGE_SIZE); - char aEmptyData[DINDEX_PAGE_SIZE]; - memset(aEmptyData,0x00,DINDEX_PAGE_SIZE); + char aEmptyData[DINDEX_PAGE_SIZE] = {}; rStream.WriteBytes(aEmptyData, DINDEX_PAGE_SIZE); } rStream.Seek(rPage.GetPagePos() * DINDEX_PAGE_SIZE); diff --git a/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx b/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx index 08da8640178d..e9082dfa05e9 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx @@ -65,9 +65,7 @@ OPreparedStatement::OPreparedStatement(OConnection* _pConnection, MYSQL_STMT* pS m_bindMetas.reserve(m_paramCount); for (unsigned i = 0; i < m_paramCount; ++i) { - MYSQL_BIND bind; - memset(&bind, 0, sizeof(MYSQL_BIND)); - m_binds.push_back(bind); + m_binds.push_back(MYSQL_BIND{}); m_bindMetas.push_back(BindMetaData{}); m_binds.back().is_null = &m_bindMetas.back().is_null; m_binds.back().length = &m_bindMetas.back().length; @@ -287,8 +285,7 @@ void SAL_CALL OPreparedStatement::setTimestamp(sal_Int32 parameter, const DateTi checkDisposed(OPreparedStatement::rBHelper.bDisposed); checkParameterIndex(parameter); - MYSQL_TIME my_time; - memset(&my_time, 0, sizeof(MYSQL_TIME)); + MYSQL_TIME my_time = {}; my_time.hour = aVal.Hours; my_time.minute = aVal.Minutes; diff --git a/connectivity/source/drivers/odbc/OConnection.cxx b/connectivity/source/drivers/odbc/OConnection.cxx index 589697f7ff72..4017a0c66041 100644 --- a/connectivity/source/drivers/odbc/OConnection.cxx +++ b/connectivity/source/drivers/odbc/OConnection.cxx @@ -92,11 +92,9 @@ SQLRETURN OConnection::OpenConnection(const OUString& aConnectStr, sal_Int32 nTi return -1; SQLRETURN nSQLRETURN = 0; - SDB_ODBC_CHAR szConnStrOut[4096]; - SDB_ODBC_CHAR szConnStrIn[2048]; + SDB_ODBC_CHAR szConnStrOut[4096] = {}; + SDB_ODBC_CHAR szConnStrIn[2048] = {}; SQLSMALLINT cbConnStrOut; - memset(szConnStrOut,'\0',4096); - memset(szConnStrIn,'\0',2048); OString aConStr(OUStringToOString(aConnectStr,getTextEncoding())); memcpy(szConnStrIn, aConStr.getStr(), std::min<sal_Int32>(sal_Int32(2048),aConStr.getLength())); diff --git a/connectivity/source/inc/dbase/DIndex.hxx b/connectivity/source/inc/dbase/DIndex.hxx index ce2a3c594998..2132f7807e1c 100644 --- a/connectivity/source/inc/dbase/DIndex.hxx +++ b/connectivity/source/inc/dbase/DIndex.hxx @@ -69,7 +69,7 @@ namespace connectivity private: std::unique_ptr<SvStream> m_pFileStream; // Stream to read/write the index - NDXHeader m_aHeader; + NDXHeader m_aHeader = {}; std::vector<ONDXPage*> m_aCollector; // Pool of obsolete pages ONDXPagePtr m_aRoot, // Root of the B+ tree diff --git a/connectivity/source/inc/dbase/DTable.hxx b/connectivity/source/inc/dbase/DTable.hxx index 7551dd01b527..f2897c19223a 100644 --- a/connectivity/source/inc/dbase/DTable.hxx +++ b/connectivity/source/inc/dbase/DTable.hxx @@ -105,7 +105,7 @@ namespace connectivity std::vector<sal_Int32> m_aPrecisions; // same as above std::vector<sal_Int32> m_aScales; std::vector<sal_Int32> m_aRealFieldLengths; - DBFHeader m_aHeader; + DBFHeader m_aHeader = {}; DBFMemoHeader m_aMemoHeader; std::unique_ptr<SvStream> m_pMemoStream; rtl_TextEncoding m_eEncoding; |