Skip to content

Commit

Permalink
Fix MSVC warnings about integer conversions in ODBC driver.
Browse files Browse the repository at this point in the history
qsql_odbc.cpp(360) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
qsql_odbc.cpp(380) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
qsql_odbc.cpp(2052) : warning C4267: 'argument' : conversion from 'size_t' to 'SQLSMALLINT', possible loss of data
qsql_odbc.cpp(2070) : warning C4267: 'argument' : conversion from 'size_t' to 'SQLSMALLINT', possible loss of data
qsql_odbc.cpp(2096) : warning C4267: 'argument' : conversion from 'size_t' to 'SQLSMALLINT', possible loss of data

Task-number: QTBUG-39388
Change-Id: Ie97d9e968d5c7b013b0d364c64175aa9b329ae97
Reviewed-by: Joerg Bornemann <[email protected]>
  • Loading branch information
Friedemann Kleint authored and Friedemann Kleint committed Oct 24, 2014
1 parent dc58c6b commit 89ae5c0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/sql/drivers/odbc/qsql_odbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni
0,
&lengthIndicator);
if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && lengthIndicator > 0)
colSize = lengthIndicator/sizeof(SQLTCHAR) + 1;
colSize = int(lengthIndicator / sizeof(SQLTCHAR) + 1);
QVarLengthArray<SQLTCHAR> buf(colSize);
memset(buf.data(), 0, colSize*sizeof(SQLTCHAR));
while (true) {
Expand All @@ -377,7 +377,7 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni
// contain the number of bytes returned - it contains the
// total number of bytes that CAN be fetched
// colSize-1: remove 0 termination when there is more data to fetch
int rSize = (r == SQL_SUCCESS_WITH_INFO) ? colSize : lengthIndicator/sizeof(SQLTCHAR);
int rSize = (r == SQL_SUCCESS_WITH_INFO) ? colSize : int(lengthIndicator / sizeof(SQLTCHAR));
fieldVal += fromSQLTCHAR(buf, rSize);
if (lengthIndicator < SQLLEN(colSize*sizeof(SQLTCHAR))) {
// workaround for Drivermanagers that don't return SQL_NO_DATA
Expand Down Expand Up @@ -2048,7 +2048,7 @@ void QODBCDriverPrivate::checkDBMS()
r = SQLGetInfo(hDbc,
SQL_DBMS_NAME,
serverString.data(),
serverString.size() * sizeof(SQLTCHAR),
SQLSMALLINT(serverString.size() * sizeof(SQLTCHAR)),
&t);
if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
const QString serverType = fromSQLTCHAR(serverString, t / sizeof(SQLTCHAR));
Expand All @@ -2066,7 +2066,7 @@ void QODBCDriverPrivate::checkDBMS()
r = SQLGetInfo(hDbc,
SQL_DRIVER_NAME,
serverString.data(),
serverString.size() * sizeof(SQLTCHAR),
SQLSMALLINT(serverString.size() * sizeof(SQLTCHAR)),
&t);
if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
const QString serverType = fromSQLTCHAR(serverString, t / sizeof(SQLTCHAR));
Expand All @@ -2092,7 +2092,7 @@ void QODBCDriverPrivate::checkHasMultiResults()
SQLRETURN r = SQLGetInfo(hDbc,
SQL_MULT_RESULT_SETS,
driverResponse.data(),
driverResponse.size() * sizeof(SQLTCHAR),
SQLSMALLINT(driverResponse.size() * sizeof(SQLTCHAR)),
&length);
if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
hasMultiResultSets = fromSQLTCHAR(driverResponse, length/sizeof(SQLTCHAR)).startsWith(QLatin1Char('Y'));
Expand Down

0 comments on commit 89ae5c0

Please sign in to comment.