summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-12-12 15:31:35 +0100
committerStephan Bergmann <sbergman@redhat.com>2016-12-12 18:02:57 +0000
commit385f6240278b38643894158d2eb7001f25fc965b (patch)
treef971df1481b714bd2f95c06bef997cf49e02243d /connectivity
parent8845ccc1d46fe09eae7b37367a6fbc774fd0b7a4 (diff)
Prevent use of ORowSetValue with sal_Bool as TINYINT
sal_Bool and sal_uInt8 are typedefs for the same underlying type, so any use of ORowSetValue with sal_Bool instead of bool, apparently intending to treat the value as a boolean, actually treated it as a TINYINT. (See e.g. recent 7b0c57b2faec875c790051d233d1e9abaed2a3bc "some compilers don't like implicit bool-to-ORowSetValue conversion".) Now that there's no way to create a sal_uInt8 ORowSetValue, getUInt8 and the m_uInt8 union member can probably go away, too. Change-Id: Ia27554f76e7e9edce6410284b578064573e54fd3 Reviewed-on: https://gerrit.libreoffice.org/31909 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/qa/connectivity/commontools/FValue_test.cxx23
-rw-r--r--connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx2
-rw-r--r--connectivity/source/commontools/FValue.cxx14
-rw-r--r--connectivity/source/drivers/file/FResultSet.cxx2
-rw-r--r--connectivity/source/drivers/firebird/DatabaseMetaData.cxx2
-rw-r--r--connectivity/source/drivers/firebird/ResultSet.cxx4
-rw-r--r--connectivity/source/drivers/odbc/OResultSet.cxx2
7 files changed, 6 insertions, 43 deletions
diff --git a/connectivity/qa/connectivity/commontools/FValue_test.cxx b/connectivity/qa/connectivity/commontools/FValue_test.cxx
index c90fa588fa5b..036fbbc3ca5f 100644
--- a/connectivity/qa/connectivity/commontools/FValue_test.cxx
+++ b/connectivity/qa/connectivity/commontools/FValue_test.cxx
@@ -34,7 +34,6 @@ public:
void test_Bool();
void test_Int8();
- void test_uInt8();
void test_Int16();
void test_uInt16();
@@ -58,7 +57,6 @@ public:
CPPUNIT_TEST(test_Bool);
CPPUNIT_TEST(test_Int8);
- CPPUNIT_TEST(test_uInt8);
CPPUNIT_TEST(test_Int16);
CPPUNIT_TEST(test_uInt16);
@@ -120,27 +118,6 @@ void FValueTest::test_Int8()
CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8 conversion from Any didn't work", trg_salInt8, src_salInt8);
}
-void FValueTest::test_uInt8()
-{
- sal_uInt8 src_saluInt8 = 255;
- ORowSetValue v(src_saluInt8);
- sal_uInt8 trg_saluInt8 = v.getUInt8();
-
- std::cerr << "src_saluInt8: " << static_cast<short>(src_saluInt8) << std::endl;
- std::cerr << "trg_saluInt8: " << static_cast<short>(trg_saluInt8) << std::endl;
-
- CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt8 conversion to ORowSetValue didn't work", trg_saluInt8, src_saluInt8);
-
- Any any_uInt8 = v.makeAny();
- ORowSetValue t;
- t.fill(any_uInt8);
- trg_saluInt8 = t.getUInt8();
-
- std::cerr << "trg_saluInt8: " << static_cast<short>(trg_saluInt8) << std::endl;
-
- CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt8 conversion from Any didn't work", trg_saluInt8, src_saluInt8);
-}
-
void FValueTest::test_Int16()
{
sal_Int16 src_salInt16 = -10001;
diff --git a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
index 3e68e4a1c8e8..3d89a552a2cc 100644
--- a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
+++ b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
@@ -206,7 +206,7 @@ Reference< css::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getChara
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
{
- return getValue(columnIndex);
+ return bool(getValue(columnIndex));
}
diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx
index 974363f8b916..71679b253827 100644
--- a/connectivity/source/commontools/FValue.cxx
+++ b/connectivity/source/commontools/FValue.cxx
@@ -586,20 +586,6 @@ ORowSetValue& ORowSetValue::operator=(sal_Int8 _rRH)
return *this;
}
-
-ORowSetValue& ORowSetValue::operator=(sal_uInt8 _rRH)
-{
- if(m_eTypeKind != DataType::TINYINT )
- free();
-
- m_aValue.m_uInt8 = _rRH;
- m_eTypeKind = DataType::TINYINT;
- m_bNull = false;
- m_bSigned = false;
- return *this;
-}
-
-
ORowSetValue& ORowSetValue::operator=(sal_Int16 _rRH)
{
if(m_eTypeKind != DataType::SMALLINT )
diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx
index f50835c30fc3..fe4341152793 100644
--- a/connectivity/source/drivers/file/FResultSet.cxx
+++ b/connectivity/source/drivers/file/FResultSet.cxx
@@ -232,7 +232,7 @@ Reference< css::io::XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_
sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
{
- return getValue(columnIndex);
+ return bool(getValue(columnIndex));
}
diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
index 1240fae101a8..f774438e6335 100644
--- a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
@@ -1836,7 +1836,7 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
aRow[4] = new ORowSetValueDecorator(xRow->getString(2)); // 4. GRANTOR
aRow[5] = new ORowSetValueDecorator(xRow->getString(3)); // 5. GRANTEE
aRow[6] = new ORowSetValueDecorator(xRow->getString(4)); // 6. Privilege
- aRow[7] = new ORowSetValueDecorator(xRow->getBoolean(5)); // 7. Is Grantable
+ aRow[7] = new ORowSetValueDecorator(bool(xRow->getBoolean(5))); // 7. Is Grantable
aResults.push_back(aRow);
}
diff --git a/connectivity/source/drivers/firebird/ResultSet.cxx b/connectivity/source/drivers/firebird/ResultSet.cxx
index 341a3237cc79..7a939402641b 100644
--- a/connectivity/source/drivers/firebird/ResultSet.cxx
+++ b/connectivity/source/drivers/firebird/ResultSet.cxx
@@ -482,7 +482,7 @@ ORowSetValue OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_S
return getString(nColumnIndex);
return getLong(nColumnIndex);
case SQL_BOOLEAN:
- return ORowSetValue(getBoolean(nColumnIndex));
+ return ORowSetValue(bool(getBoolean(nColumnIndex)));
case SQL_BLOB:
case SQL_NULL:
case SQL_QUAD:
@@ -645,7 +645,7 @@ sal_Bool SAL_CALL OResultSet::wasNull() throw(SQLException, RuntimeException, st
sal_Bool SAL_CALL OResultSet::getBoolean(sal_Int32 nColumnIndex)
throw(SQLException, RuntimeException, std::exception)
{
- return safelyRetrieveValue< sal_Bool >(nColumnIndex, SQL_BOOLEAN);
+ return safelyRetrieveValue< bool >(nColumnIndex, SQL_BOOLEAN);
}
sal_Int8 SAL_CALL OResultSet::getByte(sal_Int32 nColumnIndex)
diff --git a/connectivity/source/drivers/odbc/OResultSet.cxx b/connectivity/source/drivers/odbc/OResultSet.cxx
index 9318d47979b3..e4e8abac9b7c 100644
--- a/connectivity/source/drivers/odbc/OResultSet.cxx
+++ b/connectivity/source/drivers/odbc/OResultSet.cxx
@@ -458,7 +458,7 @@ template < typename T > T OResultSet::getValue( sal_Int32 columnIndex )
}
sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
{
- return getValue<sal_Bool>( columnIndex );
+ return getValue<bool>( columnIndex );
}
sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)