diff --git a/source/shared/core_conn.cpp b/source/shared/core_conn.cpp index 0de3e5ec..750e32ab 100644 --- a/source/shared/core_conn.cpp +++ b/source/shared/core_conn.cpp @@ -143,8 +143,7 @@ sqlsrv_conn* core_sqlsrv_connect( sqlsrv_context& henv_cp, sqlsrv_context& henv_ } SQLSMALLINT output_conn_size; - r = SQLDriverConnectW( conn->handle(), NULL, reinterpret_cast(wconn_string.get()), - static_cast(wconn_len), NULL, 0, &output_conn_size, SQL_DRIVER_NOPROMPT); + r = SQLDriverConnectW( conn->handle(), NULL, reinterpret_cast(wconn_string.get()), static_cast( wconn_len ), NULL, 0, &output_conn_size, SQL_DRIVER_NOPROMPT ); // clear the connection string from memory to remove sensitive data (such as a password). memset( const_cast(conn_str.c_str()), 0, conn_str.size()); diff --git a/source/shared/core_init.cpp b/source/shared/core_init.cpp index 02b9e4b9..4bf80167 100644 --- a/source/shared/core_init.cpp +++ b/source/shared/core_init.cpp @@ -53,7 +53,7 @@ void core_sqlsrv_minit( sqlsrv_context** henv_cp, sqlsrv_context** henv_ncp, err LOG( SEV_ERROR, "Failed to retrieve Windows version information." ); throw core::CoreException(); } -#endif +#endif //_WIN32 SQLHANDLE henv = SQL_NULL_HANDLE; SQLRETURN r; diff --git a/source/shared/core_results.cpp b/source/shared/core_results.cpp index 0499c57c..f70cd8c6 100644 --- a/source/shared/core_results.cpp +++ b/source/shared/core_results.cpp @@ -26,7 +26,7 @@ #ifndef _WIN32 #include #include -#endif // _WIN32 +#endif // !_WIN32 using namespace core; @@ -122,7 +122,7 @@ size_t get_float_precision(SQLLEN buffer_length, size_t unitsize) #ifndef _WIN32 // copy the number into a char string using the num_put facet template -SQLRETURN get_string_from_stream(Number number_data, std::basic_string &str_num, size_t precision, sqlsrv_error_auto_ptr& last_error) +SQLRETURN get_string_from_stream( Number number_data, std::basic_string &str_num, size_t precision, sqlsrv_error_auto_ptr& last_error) { //std::locale loc( std::locale(""), new std::num_put ); // By default, SQL Server doesn't take user's locale into consideration std::locale loc; @@ -236,7 +236,6 @@ SQLRETURN number_to_string( Number* number_data, _Out_ void* buffer, SQLLEN buff #endif // _WIN32 - } template @@ -828,7 +827,7 @@ SQLRETURN sqlsrv_buffered_result_set::get_data( SQLUSMALLINT field_index, SQLSMA // check to make sure the conversion type is valid - conv_matrix_t::const_iterator conv_iter = conv_matrix.find(meta[field_index].c_type); + conv_matrix_t::const_iterator conv_iter = conv_matrix.find( meta[field_index].c_type ); if( conv_iter == conv_matrix.end() || conv_iter->second.find( target_type ) == conv_iter->second.end() ) { last_error = new (sqlsrv_malloc( sizeof( sqlsrv_error ))) sqlsrv_error( (SQLCHAR*) "07006", (SQLCHAR*) "Restricted data type attribute violation", 0 ); diff --git a/source/shared/core_stmt.cpp b/source/shared/core_stmt.cpp index 5952d55b..95ce194e 100644 --- a/source/shared/core_stmt.cpp +++ b/source/shared/core_stmt.cpp @@ -233,7 +233,7 @@ sqlsrv_stmt* core_sqlsrv_create_stmt( sqlsrv_conn* conn, driver_stmt_factory stm { sqlsrv_malloc_auto_ptr stmt; SQLHANDLE stmt_h = SQL_NULL_HANDLE; - sqlsrv_stmt* return_stmt; + sqlsrv_stmt* return_stmt = NULL; try { @@ -1169,19 +1169,11 @@ void core_sqlsrv_set_query_timeout( sqlsrv_stmt* stmt, long timeout TSRMLS_DC ) // set the LOCK_TIMEOUT on the server. char lock_timeout_sql[ 32 ]; -#ifndef _WIN32 - int written = snprintf( lock_timeout_sql, sizeof( lock_timeout_sql ), "SET LOCK_TIMEOUT %d", - lock_timeout ); + + int written = snprintf( lock_timeout_sql, sizeof( lock_timeout_sql ), "SET LOCK_TIMEOUT %d", lock_timeout ); SQLSRV_ASSERT( (written != -1 && written != sizeof( lock_timeout_sql )), "stmt_option_query_timeout: snprintf failed. Shouldn't ever fail." ); -#else - int written = sprintf_s( lock_timeout_sql, sizeof( lock_timeout_sql ), "SET LOCK_TIMEOUT %d", - lock_timeout ); - - SQLSRV_ASSERT( (written != -1 && written != sizeof( lock_timeout_sql )), - "stmt_option_query_timeout: sprintf_s failed. Shouldn't ever fail." ); -#endif // !_WIN32 - + core::SQLExecDirect( stmt, lock_timeout_sql TSRMLS_CC ); stmt->query_timeout = timeout; @@ -1266,12 +1258,13 @@ bool core_sqlsrv_send_stream_packet( sqlsrv_stmt* stmt TSRMLS_DC ) // the size of wbuffer is set for the worst case of UTF-8 to UTF-16 conversion, which is a // expansion of 2x the UTF-8 size. SQLWCHAR wbuffer[ PHP_STREAM_BUFFER_SIZE + 1 ]; + int wbuffer_size = static_cast( sizeof( wbuffer ) / sizeof( SQLWCHAR )); DWORD last_error_code = ERROR_SUCCESS; // buffer_size is the # of wchars. Since it set to stmt->param_buffer_size / 2, this is accurate #ifndef _WIN32 - int wsize = SystemLocale::ToUtf16Strict( stmt->current_stream.encoding, buffer, static_cast(read), wbuffer, static_cast(sizeof( wbuffer ) / sizeof( SQLWCHAR )), &last_error_code ); + int wsize = SystemLocale::ToUtf16Strict( stmt->current_stream.encoding, buffer, static_cast(read), wbuffer, wbuffer_size, &last_error_code ); #else - int wsize = MultiByteToWideChar( stmt->current_stream.encoding, MB_ERR_INVALID_CHARS, buffer, static_cast( read ), wbuffer, static_cast( sizeof( wbuffer ) / sizeof( wchar_t ))); + int wsize = MultiByteToWideChar( stmt->current_stream.encoding, MB_ERR_INVALID_CHARS, buffer, static_cast( read ), wbuffer, wbuffer_size ); last_error_code = GetLastError(); #endif // !_WIN32 diff --git a/source/shared/typedefs_for_linux.h b/source/shared/typedefs_for_linux.h index f79de6b0..24966305 100644 --- a/source/shared/typedefs_for_linux.h +++ b/source/shared/typedefs_for_linux.h @@ -34,12 +34,6 @@ #define LANG_NEUTRAL 0x00 #define SUBLANG_DEFAULT 0x01 // user default -// #ifndef _GETLASTERROR -// #define _GETLASTERROR -// void SSetLastError(DWORD err); -// unsigned int GGetLastError(); -// #endif - DWORD FormatMessageA( DWORD dwFlags, LPCVOID lpSource, diff --git a/source/shared/xplat.h b/source/shared/xplat.h index 8effc908..7bc12faa 100644 --- a/source/shared/xplat.h +++ b/source/shared/xplat.h @@ -448,9 +448,6 @@ VerSetConditionMask( ); - -//#include - //// ntdef.h #define __unaligned #ifndef UNALIGNED