fix warning according to prefast code analysis
This commit is contained in:
parent
ef3601428b
commit
ad29c28dc4
|
@ -1301,7 +1301,7 @@ char * pdo_sqlsrv_dbh_last_id( _Inout_ pdo_dbh_t *dbh, _In_z_ const char *name,
|
||||||
|
|
||||||
sqlsrv_malloc_auto_ptr<SQLWCHAR> wsql_string;
|
sqlsrv_malloc_auto_ptr<SQLWCHAR> wsql_string;
|
||||||
unsigned int wsql_len;
|
unsigned int wsql_len;
|
||||||
wsql_string = utf16_string_from_mbcs_string( SQLSRV_ENCODING_CHAR, reinterpret_cast<const char*>( last_insert_id_query ), strlen(last_insert_id_query), &wsql_len );
|
wsql_string = utf16_string_from_mbcs_string( SQLSRV_ENCODING_CHAR, reinterpret_cast<const char*>( last_insert_id_query ), static_cast<unsigned int>( strlen( last_insert_id_query )), &wsql_len );
|
||||||
|
|
||||||
CHECK_CUSTOM_ERROR( wsql_string == 0, driver_stmt, SQLSRV_ERROR_QUERY_STRING_ENCODING_TRANSLATE, get_last_error_message() ) {
|
CHECK_CUSTOM_ERROR( wsql_string == 0, driver_stmt, SQLSRV_ERROR_QUERY_STRING_ENCODING_TRANSLATE, get_last_error_message() ) {
|
||||||
throw core::CoreException();
|
throw core::CoreException();
|
||||||
|
|
|
@ -33,7 +33,7 @@ char EXCEPTION_PROPERTY_ERRORINFO[] = "errorInfo";
|
||||||
const int MAX_DIGITS = 11; // +-2 billion = 10 digits + 1 for the sign if negative
|
const int MAX_DIGITS = 11; // +-2 billion = 10 digits + 1 for the sign if negative
|
||||||
|
|
||||||
// the warning message is not the error message alone; it must take WARNING_TEMPLATE above into consideration without the formats
|
// the warning message is not the error message alone; it must take WARNING_TEMPLATE above into consideration without the formats
|
||||||
const int WARNING_MIN_LENGTH = strlen(WARNING_TEMPLATE) - strlen("%1!s!%2!d!%3!s!");
|
const int WARNING_MIN_LENGTH = static_cast<const int>( strlen( WARNING_TEMPLATE ) - strlen( "%1!s!%2!d!%3!s!" ));
|
||||||
|
|
||||||
// buffer used to hold a formatted log message prior to actually logging it.
|
// buffer used to hold a formatted log message prior to actually logging it.
|
||||||
const int LOG_MSG_SIZE = 2048;
|
const int LOG_MSG_SIZE = 2048;
|
||||||
|
|
|
@ -305,7 +305,7 @@ bool core_compare_error_state( _In_ sqlsrv_conn* conn, _In_ SQLRETURN rc, _In_
|
||||||
if( SQL_SUCCEEDED( rc ) )
|
if( SQL_SUCCEEDED( rc ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SQLCHAR state[ SQL_SQLSTATE_BUFSIZE ];
|
SQLCHAR state[ SQL_SQLSTATE_BUFSIZE ] = { 0 };
|
||||||
SQLSMALLINT len;
|
SQLSMALLINT len;
|
||||||
SQLRETURN sr = SQLGetDiagField( SQL_HANDLE_DBC, conn->handle(), 1, SQL_DIAG_SQLSTATE, state, SQL_SQLSTATE_BUFSIZE, &len );
|
SQLRETURN sr = SQLGetDiagField( SQL_HANDLE_DBC, conn->handle(), 1, SQL_DIAG_SQLSTATE, state, SQL_SQLSTATE_BUFSIZE, &len );
|
||||||
|
|
||||||
|
@ -321,13 +321,12 @@ bool core_compare_error_state( _In_ sqlsrv_conn* conn, _In_ SQLRETURN rc, _In_
|
||||||
|
|
||||||
bool core_search_odbc_driver_unix( _In_ DRIVER_VERSION driver_version )
|
bool core_search_odbc_driver_unix( _In_ DRIVER_VERSION driver_version )
|
||||||
{
|
{
|
||||||
|
#ifndef _WIN32
|
||||||
char szBuf[DEFAULT_CONN_STR_LEN+1]; // use a large enough buffer size
|
char szBuf[DEFAULT_CONN_STR_LEN+1]; // use a large enough buffer size
|
||||||
WORD cbBufMax = DEFAULT_CONN_STR_LEN;
|
WORD cbBufMax = DEFAULT_CONN_STR_LEN;
|
||||||
WORD cbBufOut;
|
WORD cbBufOut;
|
||||||
char *pszBuf = szBuf;
|
char *pszBuf = szBuf;
|
||||||
bool found_driver = false;
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
// get all the names of the installed drivers delimited by null characters
|
// get all the names of the installed drivers delimited by null characters
|
||||||
if(! SQLGetInstalledDrivers( szBuf, cbBufMax, &cbBufOut ) )
|
if(! SQLGetInstalledDrivers( szBuf, cbBufMax, &cbBufOut ) )
|
||||||
{
|
{
|
||||||
|
@ -966,8 +965,8 @@ void load_configure_ksp( _Inout_ sqlsrv_conn* conn TSRMLS_DC )
|
||||||
|
|
||||||
char* ksp_name = Z_STRVAL_P( conn->ce_option.ksp_name );
|
char* ksp_name = Z_STRVAL_P( conn->ce_option.ksp_name );
|
||||||
char* ksp_path = Z_STRVAL_P( conn->ce_option.ksp_path );
|
char* ksp_path = Z_STRVAL_P( conn->ce_option.ksp_path );
|
||||||
unsigned int name_len = Z_STRLEN_P( conn->ce_option.ksp_name );
|
unsigned int name_len = static_cast<unsigned int>( Z_STRLEN_P( conn->ce_option.ksp_name ));
|
||||||
unsigned int key_size = conn->ce_option.key_size;
|
unsigned int key_size = static_cast<unsigned int>( conn->ce_option.key_size );
|
||||||
|
|
||||||
sqlsrv_malloc_auto_ptr<unsigned char> ksp_data;
|
sqlsrv_malloc_auto_ptr<unsigned char> ksp_data;
|
||||||
|
|
||||||
|
|
|
@ -2267,10 +2267,11 @@ namespace core {
|
||||||
SQLRETURN r;
|
SQLRETURN r;
|
||||||
SQLHDESC hIpd = NULL;
|
SQLHDESC hIpd = NULL;
|
||||||
core::SQLGetStmtAttr( stmt, SQL_ATTR_IMP_PARAM_DESC, &hIpd, 0, 0 );
|
core::SQLGetStmtAttr( stmt, SQL_ATTR_IMP_PARAM_DESC, &hIpd, 0, 0 );
|
||||||
r = ::SQLSetDescField( hIpd, rec_num, fld_id, value_ptr, str_len );
|
if( value_ptr ) {
|
||||||
|
r = ::SQLSetDescField( hIpd, rec_num, fld_id, value_ptr, str_len );
|
||||||
CHECK_SQL_ERROR_OR_WARNING( r, stmt ) {
|
CHECK_SQL_ERROR_OR_WARNING( r, stmt ) {
|
||||||
throw CoreException();
|
throw CoreException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2670,12 +2670,12 @@ void adjustInputPrecision( _Inout_ zval* param_z, _In_ SQLSMALLINT decimal_digit
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::vector<size_t> digits;
|
std::vector<size_t> digits;
|
||||||
char* ptr = ZSTR_VAL( Z_STR_P( param_z ));
|
unsigned char* ptr = reinterpret_cast<unsigned char*>(ZSTR_VAL( Z_STR_P( param_z )));
|
||||||
bool isNeg = false;
|
bool isNeg = false;
|
||||||
bool isScientificNot = false;
|
bool isScientificNot = false;
|
||||||
char scientificChar = ' ';
|
char scientificChar = ' ';
|
||||||
short scientificExp = 0;
|
short scientificExp = 0;
|
||||||
if( strchr( ptr, 'e' ) || strchr( ptr, 'E' )){
|
if( strchr( reinterpret_cast<char*>( ptr ), 'e' ) || strchr( reinterpret_cast<char*>( ptr ), 'E' )){
|
||||||
isScientificNot = true;
|
isScientificNot = true;
|
||||||
}
|
}
|
||||||
// parse digits in param_z into the vector digits
|
// parse digits in param_z into the vector digits
|
||||||
|
@ -2754,7 +2754,7 @@ void adjustInputPrecision( _Inout_ zval* param_z, _In_ SQLSMALLINT decimal_digit
|
||||||
// check if the last digit to be popped is greater than 5, if so, the digit before it needs to round up
|
// check if the last digit to be popped is greater than 5, if so, the digit before it needs to round up
|
||||||
carryOver = digits.back() >= 5;
|
carryOver = digits.back() >= 5;
|
||||||
digits.pop_back();
|
digits.pop_back();
|
||||||
backInd = digits.size() - 1;
|
backInd = static_cast<short>(digits.size() - 1);
|
||||||
// round up from the end until no more carry over
|
// round up from the end until no more carry over
|
||||||
while( carryOver && backInd >= 0 ){
|
while( carryOver && backInd >= 0 ){
|
||||||
if( digits.at( backInd ) != 9 ){
|
if( digits.at( backInd ) != 9 ){
|
||||||
|
|
|
@ -263,7 +263,7 @@ bool core_sqlsrv_get_odbc_error( _Inout_ sqlsrv_context& ctx, _In_ int record_nu
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to calculate number of characters
|
// We need to calculate number of characters
|
||||||
SQLLEN wsqlstate_len = sizeof( wsqlstate ) / sizeof( SQLWCHAR );
|
SQLINTEGER wsqlstate_len = sizeof( wsqlstate ) / sizeof( SQLWCHAR );
|
||||||
SQLLEN sqlstate_len = 0;
|
SQLLEN sqlstate_len = 0;
|
||||||
convert_string_from_utf16(enc, wsqlstate, wsqlstate_len, (char**)&error->sqlstate, sqlstate_len);
|
convert_string_from_utf16(enc, wsqlstate, wsqlstate_len, (char**)&error->sqlstate, sqlstate_len);
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ void __cdecl sqlsrv_conn_dtor( _Inout_ zend_resource *rsrc TSRMLS_DC );
|
||||||
// holds the field names for reuse by sqlsrv_fetch_array/object as keys
|
// holds the field names for reuse by sqlsrv_fetch_array/object as keys
|
||||||
struct sqlsrv_fetch_field_name {
|
struct sqlsrv_fetch_field_name {
|
||||||
char* name;
|
char* name;
|
||||||
unsigned int len;
|
SQLLEN len;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct stmt_option_ss_scrollable : public stmt_option_functor {
|
struct stmt_option_ss_scrollable : public stmt_option_functor {
|
||||||
|
|
|
@ -1229,7 +1229,7 @@ void bind_params( _Inout_ ss_sqlsrv_stmt* stmt TSRMLS_DC )
|
||||||
}
|
}
|
||||||
// bind the parameter
|
// bind the parameter
|
||||||
SQLSRV_ASSERT( value_z != NULL, "bind_params: value_z is null." );
|
SQLSRV_ASSERT( value_z != NULL, "bind_params: value_z is null." );
|
||||||
core_sqlsrv_bind_param( stmt, index, direction, value_z, php_out_type, encoding, sql_type, column_size,
|
core_sqlsrv_bind_param( stmt, static_cast<SQLUSMALLINT>( index ), direction, value_z, php_out_type, encoding, sql_type, column_size,
|
||||||
decimal_digits TSRMLS_CC );
|
decimal_digits TSRMLS_CC );
|
||||||
|
|
||||||
} ZEND_HASH_FOREACH_END();
|
} ZEND_HASH_FOREACH_END();
|
||||||
|
|
Loading…
Reference in a new issue