summaryrefslogtreecommitdiff
path: root/mysqlc/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-08-13 09:09:18 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-13 09:51:49 +0200
commitce24919c01d1ab77f962137ff04a31dd5ec944af (patch)
tree19b1718b4de893c736db1df43b0ebf9d4795f39c /mysqlc/source
parent85f141b533b9b778971ddf755d93df09f92d495d (diff)
loplugin, various in mysqlc
including redundantcast implicitboolconversion sallogareas after commit 3478d7453a3d65b3d8d164e8f898a0b79f005c58 Date: Sun Jun 17 18:09:43 2018 +0200 Switch from mysql to MariaDB C API Change-Id: Ibbb2fccdc8c7837412d878752f7da780140d678c
Diffstat (limited to 'mysqlc/source')
-rw-r--r--mysqlc/source/mysqlc_connection.cxx4
-rw-r--r--mysqlc/source/mysqlc_databasemetadata.cxx2
-rw-r--r--mysqlc/source/mysqlc_general.cxx2
-rw-r--r--mysqlc/source/mysqlc_prepared_resultset.cxx42
-rw-r--r--mysqlc/source/mysqlc_preparedstatement.cxx2
-rw-r--r--mysqlc/source/mysqlc_resultsetmetadata.cxx4
6 files changed, 28 insertions, 28 deletions
diff --git a/mysqlc/source/mysqlc_connection.cxx b/mysqlc/source/mysqlc_connection.cxx
index 73581734a293..02b6af026534 100644
--- a/mysqlc/source/mysqlc_connection.cxx
+++ b/mysqlc/source/mysqlc_connection.cxx
@@ -79,7 +79,7 @@ OConnection::OConnection(MysqlCDriver& _rDriver)
// use TCP as connection
mysql_protocol_type protocol = MYSQL_PROTOCOL_TCP;
- mysql_options(&m_mysql, MYSQL_OPT_PROTOCOL, reinterpret_cast<int*>(&protocol));
+ mysql_options(&m_mysql, MYSQL_OPT_PROTOCOL, &protocol);
}
OConnection::~OConnection()
@@ -277,7 +277,7 @@ void SAL_CALL OConnection::setAutoCommit(sal_Bool autoCommit)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
- if(!mysql_autocommit(&m_mysql, autoCommit))
+ if(!mysql_autocommit(&m_mysql, static_cast<my_bool>(autoCommit)))
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(&m_mysql), mysql_errno(&m_mysql), *this, getConnectionEncoding());
}
diff --git a/mysqlc/source/mysqlc_databasemetadata.cxx b/mysqlc/source/mysqlc_databasemetadata.cxx
index 0f9e539e6df3..a63a7fe0f5a5 100644
--- a/mysqlc/source/mysqlc_databasemetadata.cxx
+++ b/mysqlc/source/mysqlc_databasemetadata.cxx
@@ -909,7 +909,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas()
for (sal_uInt32 i = 1; i <= columns; i++) {
rtl::OUString columnStringValue = xRow->getString(i);
if (i == 1) { // TABLE_SCHEM
- informationSchema = (0 == columnStringValue.equalsIgnoreAsciiCase("information_schema"));
+ informationSchema = !columnStringValue.equalsIgnoreAsciiCase("information_schema");
}
aRow.push_back(makeAny(columnStringValue));
}
diff --git a/mysqlc/source/mysqlc_general.cxx b/mysqlc/source/mysqlc_general.cxx
index 22e771275328..48b68d081ff7 100644
--- a/mysqlc/source/mysqlc_general.cxx
+++ b/mysqlc/source/mysqlc_general.cxx
@@ -84,7 +84,7 @@ void allocateSqlVar(void** mem, enum_field_types eType, unsigned nSize)
*mem = nullptr;
break;
default:
- SAL_WARN("connectivity","unknown enum_field_type");
+ SAL_WARN("mysqlc","unknown enum_field_type");
}
}
diff --git a/mysqlc/source/mysqlc_prepared_resultset.cxx b/mysqlc/source/mysqlc_prepared_resultset.cxx
index 6ef50bea7116..d66259d0a9db 100644
--- a/mysqlc/source/mysqlc_prepared_resultset.cxx
+++ b/mysqlc/source/mysqlc_prepared_resultset.cxx
@@ -168,7 +168,7 @@ sal_Bool SAL_CALL OPreparedResultSet::getBoolean(sal_Int32 column)
return false;
}
m_bWasNull = false;
- return *reinterpret_cast<bool*>(m_aData[column - 1].buffer);
+ return *static_cast<bool*>(m_aData[column - 1].buffer);
}
sal_Int8 SAL_CALL OPreparedResultSet::getByte(sal_Int32 column)
@@ -183,7 +183,7 @@ sal_Int8 SAL_CALL OPreparedResultSet::getByte(sal_Int32 column)
return 0;
}
m_bWasNull = false;
- return *reinterpret_cast<sal_Int8*>(m_aData[column - 1].buffer);
+ return *static_cast<sal_Int8*>(m_aData[column - 1].buffer);
}
uno::Sequence<sal_Int8> SAL_CALL OPreparedResultSet::getBytes(sal_Int32 column)
@@ -198,7 +198,7 @@ uno::Sequence<sal_Int8> SAL_CALL OPreparedResultSet::getBytes(sal_Int32 column)
}
m_bWasNull = false;
- return uno::Sequence<sal_Int8>(reinterpret_cast<sal_Int8 const*>(m_aData[column - 1].buffer),
+ return uno::Sequence<sal_Int8>(static_cast<sal_Int8 const*>(m_aData[column - 1].buffer),
*m_aData[column - 1].length);
}
@@ -215,7 +215,7 @@ Date SAL_CALL OPreparedResultSet::getDate(sal_Int32 column)
}
m_bWasNull = false;
- const MYSQL_TIME* pTime = reinterpret_cast<MYSQL_TIME*>(m_aData[column - 1].buffer);
+ const MYSQL_TIME* pTime = static_cast<MYSQL_TIME*>(m_aData[column - 1].buffer);
assert(pTime != nullptr);
@@ -235,14 +235,14 @@ double SAL_CALL OPreparedResultSet::getDouble(sal_Int32 column)
if (*m_aData[column - 1].is_null)
{
m_bWasNull = true;
- return double{};
+ return 0;
}
m_bWasNull = false;
if (m_aFields[column - 1].type == MYSQL_TYPE_FLOAT)
- return *reinterpret_cast<float*>(m_aData[column - 1].buffer);
+ return *static_cast<float*>(m_aData[column - 1].buffer);
- return *reinterpret_cast<double*>(m_aData[column - 1].buffer);
+ return *static_cast<double*>(m_aData[column - 1].buffer);
}
float SAL_CALL OPreparedResultSet::getFloat(sal_Int32 column)
@@ -254,11 +254,11 @@ float SAL_CALL OPreparedResultSet::getFloat(sal_Int32 column)
if (*m_aData[column - 1].is_null)
{
m_bWasNull = true;
- return float{};
+ return 0;
}
m_bWasNull = false;
- return *reinterpret_cast<float*>(m_aData[column - 1].buffer);
+ return *static_cast<float*>(m_aData[column - 1].buffer);
}
sal_Int32 SAL_CALL OPreparedResultSet::getInt(sal_Int32 column)
@@ -268,11 +268,11 @@ sal_Int32 SAL_CALL OPreparedResultSet::getInt(sal_Int32 column)
if (*m_aData[column - 1].is_null)
{
m_bWasNull = true;
- return sal_Int32{};
+ return 0;
}
m_bWasNull = false;
- return *reinterpret_cast<sal_Int32*>(m_aData[column - 1].buffer);
+ return *static_cast<sal_Int32*>(m_aData[column - 1].buffer);
}
sal_Int32 SAL_CALL OPreparedResultSet::getRow()
@@ -290,9 +290,9 @@ sal_Int64 SAL_CALL OPreparedResultSet::getLong(sal_Int32 column)
checkColumnIndex(column);
if (*m_aData[column - 1].is_null)
- return sal_Int64{};
+ return 0;
- return *reinterpret_cast<sal_Int64*>(m_aData[column - 1].buffer);
+ return *static_cast<sal_Int64*>(m_aData[column - 1].buffer);
}
uno::Reference<XResultSetMetaData> SAL_CALL OPreparedResultSet::getMetaData()
@@ -368,11 +368,11 @@ sal_Int16 SAL_CALL OPreparedResultSet::getShort(sal_Int32 column)
if (*m_aData[column - 1].is_null)
{
m_bWasNull = true;
- return sal_Int16{};
+ return 0;
}
m_bWasNull = false;
- return *reinterpret_cast<sal_Int16*>(m_aData[column - 1].buffer);
+ return *static_cast<sal_Int16*>(m_aData[column - 1].buffer);
}
rtl::OUString SAL_CALL OPreparedResultSet::getString(sal_Int32 column)
@@ -389,12 +389,12 @@ rtl::OUString SAL_CALL OPreparedResultSet::getString(sal_Int32 column)
if (m_aFields[column - 1].type == MYSQL_TYPE_BIT)
{
- if (*reinterpret_cast<sal_Int8*>(m_aData[column - 1].buffer) != 0)
+ if (*static_cast<sal_Int8*>(m_aData[column - 1].buffer) != 0)
return OUString{ "YES" };
return OUString{ "NO" };
}
- const char* sStr = reinterpret_cast<const char*>(m_aData[column - 1].buffer);
+ const char* sStr = static_cast<const char*>(m_aData[column - 1].buffer);
OUString sReturn = rtl::OUString(sStr, *m_aData[column - 1].length, m_encoding);
return sReturn;
@@ -413,7 +413,7 @@ Time SAL_CALL OPreparedResultSet::getTime(sal_Int32 column)
}
m_bWasNull = false;
- const MYSQL_TIME* pTime = reinterpret_cast<MYSQL_TIME*>(m_aData[column - 1].buffer);
+ const MYSQL_TIME* pTime = static_cast<MYSQL_TIME*>(m_aData[column - 1].buffer);
assert(pTime != nullptr);
@@ -437,7 +437,7 @@ DateTime SAL_CALL OPreparedResultSet::getTimestamp(sal_Int32 column)
}
m_bWasNull = false;
- const MYSQL_TIME* pTime = reinterpret_cast<MYSQL_TIME*>(m_aData[column - 1].buffer);
+ const MYSQL_TIME* pTime = static_cast<MYSQL_TIME*>(m_aData[column - 1].buffer);
assert(pTime != nullptr);
@@ -544,7 +544,7 @@ sal_Bool SAL_CALL OPreparedResultSet::absolute(sal_Int32 row)
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedResultSet_BASE::rBHelper.bDisposed);
- sal_Int32 nFields = static_cast<sal_Int32>(m_nFieldCount);
+ sal_Int32 nFields = m_nFieldCount;
sal_Int32 nToGo = row < 0 ? nFields - row : row - 1;
if (nToGo >= nFields)
@@ -563,7 +563,7 @@ sal_Bool SAL_CALL OPreparedResultSet::relative(sal_Int32 row)
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedResultSet_BASE::rBHelper.bDisposed);
- sal_Int32 nFields = static_cast<sal_Int32>(m_nFieldCount);
+ sal_Int32 nFields = m_nFieldCount;
if (row == 0)
return true;
diff --git a/mysqlc/source/mysqlc_preparedstatement.cxx b/mysqlc/source/mysqlc_preparedstatement.cxx
index 40e2ef172d8f..35d1930f097b 100644
--- a/mysqlc/source/mysqlc_preparedstatement.cxx
+++ b/mysqlc/source/mysqlc_preparedstatement.cxx
@@ -139,7 +139,7 @@ void SAL_CALL OPreparedStatement::close()
if(mysql_stmt_close(m_pStmt))
{
- SAL_WARN("connectivity", "failed to close mysql prepared statement");
+ SAL_WARN("mysqlc", "failed to close mysql prepared statement");
}
m_pStmt = nullptr; // it's deallocated already
clearWarnings();
diff --git a/mysqlc/source/mysqlc_resultsetmetadata.cxx b/mysqlc/source/mysqlc_resultsetmetadata.cxx
index 0c54ec5021ed..c260e4bc4bc0 100644
--- a/mysqlc/source/mysqlc_resultsetmetadata.cxx
+++ b/mysqlc/source/mysqlc_resultsetmetadata.cxx
@@ -136,7 +136,7 @@ sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement(sal_Int32 column)
checkColumnIndex(column);
MYSQL_FIELD* pField = getField(column);
- return pField->flags & AUTO_INCREMENT_FLAG;
+ return (pField->flags & AUTO_INCREMENT_FLAG) != 0;
}
sal_Bool SAL_CALL OResultSetMetaData::isSigned(sal_Int32 column)
@@ -165,7 +165,7 @@ sal_Int32 SAL_CALL OResultSetMetaData::isNullable(sal_Int32 column)
{
checkColumnIndex(column);
MYSQL_FIELD* pField = getField(column);
- return !(pField->flags & NOT_NULL_FLAG);
+ return sal_Int32((pField->flags & NOT_NULL_FLAG) != 0);
}
sal_Bool SAL_CALL OResultSetMetaData::isSearchable(sal_Int32 /*column*/)