From 89ae5c03a21f15b5f2abad23c6963c15772600eb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 23 Oct 2014 14:58:25 +0200 Subject: [PATCH] Fix MSVC warnings about integer conversions in ODBC driver. 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 --- src/sql/drivers/odbc/qsql_odbc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 1644b571848..dc2a18030bd 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -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 buf(colSize); memset(buf.data(), 0, colSize*sizeof(SQLTCHAR)); while (true) { @@ -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 @@ -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)); @@ -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)); @@ -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'));