From 537ae2d27d5223d0617e4e941981456aee9f4322 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Fri, 16 Oct 2020 15:17:58 -0700 Subject: [PATCH] Minimized warnings during compilation (#1205) --- source/pdo_sqlsrv/pdo_init.cpp | 12 ++++----- source/pdo_sqlsrv/pdo_util.cpp | 6 ++--- source/pdo_sqlsrv/php_pdo_sqlsrv_int.h | 6 ++--- source/shared/core_results.cpp | 8 +++--- source/shared/core_sqlsrv.h | 18 ++++++------- source/shared/core_stmt.cpp | 36 +++++++++++++------------- source/shared/localizationimpl.cpp | 24 ++++++++--------- source/sqlsrv/conn.cpp | 5 +++- source/sqlsrv/init.cpp | 12 ++++----- source/sqlsrv/php_sqlsrv_int.h | 6 ++--- source/sqlsrv/util.cpp | 12 ++++----- 11 files changed, 74 insertions(+), 71 deletions(-) diff --git a/source/pdo_sqlsrv/pdo_init.cpp b/source/pdo_sqlsrv/pdo_init.cpp index 82ff1e10..0c040159 100644 --- a/source/pdo_sqlsrv/pdo_init.cpp +++ b/source/pdo_sqlsrv/pdo_init.cpp @@ -116,7 +116,7 @@ void pdo_error_dtor( _Inout_ zval* elem ) { PHP_MINIT_FUNCTION(pdo_sqlsrv) { - SQLSRV_UNUSED( type ); + // SQLSRV_UNUSED( type ); // our global variables are initialized in the RINIT function #if defined(ZTS) @@ -185,7 +185,7 @@ PHP_MSHUTDOWN_FUNCTION(pdo_sqlsrv) { try { - SQLSRV_UNUSED( type ); + // SQLSRV_UNUSED( type ); UNREGISTER_INI_ENTRIES(); @@ -213,8 +213,8 @@ PHP_MSHUTDOWN_FUNCTION(pdo_sqlsrv) PHP_RINIT_FUNCTION(pdo_sqlsrv) { - SQLSRV_UNUSED( module_number ); - SQLSRV_UNUSED( type ); + // SQLSRV_UNUSED( module_number ); + // SQLSRV_UNUSED( type ); #if defined(ZTS) ZEND_TSRMLS_CACHE_UPDATE(); @@ -247,8 +247,8 @@ PHP_RINIT_FUNCTION(pdo_sqlsrv) PHP_RSHUTDOWN_FUNCTION(pdo_sqlsrv) { - SQLSRV_UNUSED( module_number ); - SQLSRV_UNUSED( type ); + // SQLSRV_UNUSED( module_number ); + // SQLSRV_UNUSED( type ); PDO_LOG_NOTICE("pdo_sqlsrv: entering rshutdown"); diff --git a/source/pdo_sqlsrv/pdo_util.cpp b/source/pdo_sqlsrv/pdo_util.cpp index c4afaa12..dd5f3179 100644 --- a/source/pdo_sqlsrv/pdo_util.cpp +++ b/source/pdo_sqlsrv/pdo_util.cpp @@ -465,7 +465,7 @@ pdo_error PDO_ERRORS[] = { { UINT_MAX, {} } }; -bool pdo_sqlsrv_handle_env_error( _Inout_ sqlsrv_context& ctx, _In_opt_ unsigned int sqlsrv_error_code, _In_opt_ bool warning, +bool pdo_sqlsrv_handle_env_error( _Inout_ sqlsrv_context& ctx, _In_opt_ unsigned int sqlsrv_error_code, _In_opt_ int warning, _In_opt_ va_list* print_args ) { SQLSRV_ASSERT((ctx != NULL), "pdo_sqlsrv_handle_env_error: sqlsrv_context was null"); @@ -488,7 +488,7 @@ bool pdo_sqlsrv_handle_env_error( _Inout_ sqlsrv_context& ctx, _In_opt_ unsigned } // pdo error handler for the dbh context. -bool pdo_sqlsrv_handle_dbh_error( _Inout_ sqlsrv_context& ctx, _In_opt_ unsigned int sqlsrv_error_code, _In_opt_ bool warning, +bool pdo_sqlsrv_handle_dbh_error( _Inout_ sqlsrv_context& ctx, _In_opt_ unsigned int sqlsrv_error_code, _In_opt_ int warning, _In_opt_ va_list* print_args ) { pdo_dbh_t* dbh = reinterpret_cast( ctx.driver()); @@ -520,7 +520,7 @@ bool pdo_sqlsrv_handle_dbh_error( _Inout_ sqlsrv_context& ctx, _In_opt_ unsigned } // PDO error handler for the statement context. -bool pdo_sqlsrv_handle_stmt_error(_Inout_ sqlsrv_context& ctx, _In_opt_ unsigned int sqlsrv_error_code, _In_opt_ bool warning, +bool pdo_sqlsrv_handle_stmt_error(_Inout_ sqlsrv_context& ctx, _In_opt_ unsigned int sqlsrv_error_code, _In_opt_ int warning, _In_opt_ va_list* print_args) { pdo_stmt_t* pdo_stmt = reinterpret_cast(ctx.driver()); diff --git a/source/pdo_sqlsrv/php_pdo_sqlsrv_int.h b/source/pdo_sqlsrv/php_pdo_sqlsrv_int.h index 79dfa7f0..68853ca3 100644 --- a/source/pdo_sqlsrv/php_pdo_sqlsrv_int.h +++ b/source/pdo_sqlsrv/php_pdo_sqlsrv_int.h @@ -285,11 +285,11 @@ struct pdo_error { // called when an error occurs in the core layer. These routines are set as the error_callback in a // context. The context is passed to this function since it contains the function -bool pdo_sqlsrv_handle_env_error( _Inout_ sqlsrv_context& ctx, _In_opt_ unsigned int sqlsrv_error_code, _In_opt_ bool warning, +bool pdo_sqlsrv_handle_env_error( _Inout_ sqlsrv_context& ctx, _In_opt_ unsigned int sqlsrv_error_code, _In_opt_ int warning, _In_opt_ va_list* print_args ); -bool pdo_sqlsrv_handle_dbh_error( _Inout_ sqlsrv_context& ctx, _In_opt_ unsigned int sqlsrv_error_code, _In_opt_ bool warning, +bool pdo_sqlsrv_handle_dbh_error( _Inout_ sqlsrv_context& ctx, _In_opt_ unsigned int sqlsrv_error_code, _In_opt_ int warning, _In_opt_ va_list* print_args ); -bool pdo_sqlsrv_handle_stmt_error( _Inout_ sqlsrv_context& ctx, _In_opt_ unsigned int sqlsrv_error_code, _In_opt_ bool warning, +bool pdo_sqlsrv_handle_stmt_error( _Inout_ sqlsrv_context& ctx, _In_opt_ unsigned int sqlsrv_error_code, _In_opt_ int warning, _In_opt_ va_list* print_args ); // common routine to transfer a sqlsrv_context's error to a PDO zval diff --git a/source/shared/core_results.cpp b/source/shared/core_results.cpp index d7a59ac1..88d3bbd0 100644 --- a/source/shared/core_results.cpp +++ b/source/shared/core_results.cpp @@ -1066,7 +1066,7 @@ SQLRETURN sqlsrv_buffered_result_set::string_to_double( _In_ SQLSMALLINT field_i double* number_data = reinterpret_cast(buffer); try { *number_data = std::stod(std::string(string_data)); - } catch (const std::logic_error& err) { + } catch (const std::logic_error& ) { last_error = new (sqlsrv_malloc(sizeof(sqlsrv_error))) sqlsrv_error((SQLCHAR*) "22003", (SQLCHAR*) "Numeric value out of range", 103); return SQL_ERROR; } @@ -1091,7 +1091,7 @@ SQLRETURN sqlsrv_buffered_result_set::wstring_to_double( _In_ SQLSMALLINT field_ #else *number_data = std::stod(getUTF8StringFromString(string_data)); #endif // _WIN32 - } catch (const std::logic_error& err) { + } catch (const std::logic_error& ) { last_error = new (sqlsrv_malloc(sizeof(sqlsrv_error))) sqlsrv_error((SQLCHAR*) "22003", (SQLCHAR*) "Numeric value out of range", 103); return SQL_ERROR; } @@ -1112,7 +1112,7 @@ SQLRETURN sqlsrv_buffered_result_set::string_to_long( _In_ SQLSMALLINT field_ind LONG* number_data = reinterpret_cast(buffer); try { *number_data = std::stol(std::string(string_data)); - } catch (const std::logic_error& err) { + } catch (const std::logic_error& ) { last_error = new (sqlsrv_malloc(sizeof(sqlsrv_error))) sqlsrv_error((SQLCHAR*) "22003", (SQLCHAR*) "Numeric value out of range", 103); return SQL_ERROR; } @@ -1137,7 +1137,7 @@ SQLRETURN sqlsrv_buffered_result_set::wstring_to_long( _In_ SQLSMALLINT field_in #else *number_data = std::stol(getUTF8StringFromString(string_data)); #endif // _WIN32 - } catch (const std::logic_error& err) { + } catch (const std::logic_error& ) { last_error = new (sqlsrv_malloc(sizeof(sqlsrv_error))) sqlsrv_error((SQLCHAR*) "22003", (SQLCHAR*) "Numeric value out of range", 103); return SQL_ERROR; } diff --git a/source/shared/core_sqlsrv.h b/source/shared/core_sqlsrv.h index f6a6809f..fc7855e9 100644 --- a/source/shared/core_sqlsrv.h +++ b/source/shared/core_sqlsrv.h @@ -876,7 +876,7 @@ struct sqlsrv_conn; // a driver specific callback for processing errors. // ctx - the context holding the handles // sqlsrv_error_code - specific error code to return. -typedef bool (*error_callback)( _Inout_ sqlsrv_context& ctx, _In_ unsigned int sqlsrv_error_code, _In_ bool error, _In_opt_ va_list* print_args ); +typedef bool (*error_callback)( _Inout_ sqlsrv_context& ctx, _In_ unsigned int sqlsrv_error_code, _In_ int error, _In_opt_ va_list* print_args ); // sqlsrv_context // a context holds relevant information to be passed with a connection and statement objects. @@ -1931,7 +1931,7 @@ DWORD core_sqlsrv_format_message( _Out_ char* output_buffer, _In_ unsigned outpu // convenience functions that overload either a reference or a pointer so we can use // either in the CHECK_* functions. -inline bool call_error_handler( _Inout_ sqlsrv_context& ctx, _In_ unsigned long sqlsrv_error_code, _In_ bool warning, ... ) +inline bool call_error_handler( _Inout_ sqlsrv_context& ctx, _In_ unsigned long sqlsrv_error_code, _In_ int warning, ... ) { va_list print_params; va_start( print_params, warning ); @@ -1940,7 +1940,7 @@ inline bool call_error_handler( _Inout_ sqlsrv_context& ctx, _In_ unsigned long return ignored; } -inline bool call_error_handler( _Inout_ sqlsrv_context* ctx, _In_ unsigned long sqlsrv_error_code, _In_ bool warning, ... ) +inline bool call_error_handler( _Inout_ sqlsrv_context* ctx, _In_ unsigned long sqlsrv_error_code, _In_ int warning, ... ) { va_list print_params; va_start( print_params, warning ); @@ -1985,7 +1985,7 @@ inline bool is_truncated_warning( _In_ SQLCHAR* state ) bool flag##unique = (condition); \ bool ignored##unique = true; \ if (flag##unique) { \ - ignored##unique = call_error_handler( context, ssphp, /*warning*/false, ## __VA_ARGS__ ); \ + ignored##unique = call_error_handler( context, ssphp, /*warning*/0, ## __VA_ARGS__ ); \ } \ if( !ignored##unique ) @@ -2005,7 +2005,7 @@ inline bool is_truncated_warning( _In_ SQLCHAR* state ) #define CHECK_WARNING_AS_ERROR_UNIQUE( unique, condition, context, ssphp, ... ) \ bool ignored##unique = true; \ if( condition ) { \ - ignored##unique = call_error_handler( context, ssphp, /*warning*/true, ## __VA_ARGS__ ); \ + ignored##unique = call_error_handler( context, ssphp, /*warning*/1, ## __VA_ARGS__ ); \ } \ if( !ignored##unique ) @@ -2014,7 +2014,7 @@ inline bool is_truncated_warning( _In_ SQLCHAR* state ) #define CHECK_SQL_WARNING( result, context, ... ) \ if( result == SQL_SUCCESS_WITH_INFO ) { \ - (void)call_error_handler( context, 0, /*warning*/ true, ## __VA_ARGS__ ); \ + (void)call_error_handler( context, 0, /*warning*/1, ## __VA_ARGS__ ); \ } #define CHECK_CUSTOM_WARNING_AS_ERROR( condition, context, ssphp, ... ) \ @@ -2027,16 +2027,16 @@ inline bool is_truncated_warning( _In_ SQLCHAR* state ) SQLSRV_ASSERT( result != SQL_INVALID_HANDLE, "Invalid handle returned." ); \ bool ignored = true; \ if( result == SQL_ERROR ) { \ - ignored = call_error_handler( context, SQLSRV_ERROR_ODBC, false, ##__VA_ARGS__ ); \ + ignored = call_error_handler( context, SQLSRV_ERROR_ODBC, 0, ##__VA_ARGS__ ); \ } \ else if( result == SQL_SUCCESS_WITH_INFO ) { \ - ignored = call_error_handler( context, SQLSRV_ERROR_ODBC, true, ##__VA_ARGS__ ); \ + ignored = call_error_handler( context, SQLSRV_ERROR_ODBC, 1, ##__VA_ARGS__ ); \ } \ if( !ignored ) // throw an exception after it has been hooked into the custom error handler #define THROW_CORE_ERROR( ctx, custom, ... ) \ - (void)call_error_handler( ctx, custom, /*warning*/ false, ## __VA_ARGS__ ); \ + (void)call_error_handler( ctx, custom, /*warning*/0, ## __VA_ARGS__ ); \ throw core::CoreException(); //********************************************************************************************************************************* diff --git a/source/shared/core_stmt.cpp b/source/shared/core_stmt.cpp index 4da01dfb..1cc35c5a 100644 --- a/source/shared/core_stmt.cpp +++ b/source/shared/core_stmt.cpp @@ -110,7 +110,7 @@ void default_sql_type( _Inout_ sqlsrv_stmt* stmt, _In_opt_ SQLULEN paramno, _In_ _Out_ SQLSMALLINT& sql_type ); void col_cache_dtor( _Inout_ zval* data_z ); void field_cache_dtor( _Inout_ zval* data_z ); -int round_up_decimal_numbers(_Inout_ char* buffer, _In_ short decimal_pos, _In_ short decimals_places, _In_ short offset, _In_ short lastpos); +int round_up_decimal_numbers(_Inout_ char* buffer, _In_ int decimal_pos, _In_ int decimals_places, _In_ int offset, _In_ int lastpos); void format_decimal_numbers(_In_ SQLSMALLINT decimals_places, _In_ SQLSMALLINT field_scale, _Inout_updates_bytes_(*field_len) char*& field_value, _Inout_ SQLLEN* field_len); void finalize_output_parameters( _Inout_ sqlsrv_stmt* stmt, _In_opt_ bool exception_thrown = false ); void get_field_as_string( _Inout_ sqlsrv_stmt* stmt, _In_ SQLUSMALLINT field_index, _Inout_ sqlsrv_phptype sqlsrv_php_type, @@ -2355,8 +2355,8 @@ void format_decimal_numbers(_In_ SQLSMALLINT decimals_places, _In_ SQLSMALLINT f } char buffer[50] = " "; // A buffer with two blank spaces, as leeway - short offset = 1 + is_negative; - short src_length = strlen(src); + int offset = 1 + is_negative; + int src_length = strlen(src); if (add_leading_zero) { buffer[offset++] = '0'; @@ -2368,7 +2368,7 @@ void format_decimal_numbers(_In_ SQLSMALLINT decimals_places, _In_ SQLSMALLINT f // If no need to adjust decimal places, skip formatting if (decimals_places != NO_CHANGE_DECIMAL_PLACES) { - short num_decimals = src_length - (pt - src) - 1; + int num_decimals = src_length - (pt - src) - 1; if (num_decimals > scale) { last_pos = round_up_decimal_numbers(buffer, (pt - src) + offset, scale, offset, last_pos); @@ -2385,7 +2385,7 @@ void format_decimal_numbers(_In_ SQLSMALLINT decimals_places, _In_ SQLSMALLINT f buffer[--offset] = '-'; } - short len = last_pos - offset; + int len = last_pos - offset; memcpy_s(field_value, len, buffer + offset, len); field_value[len] = '\0'; *field_len = len; @@ -3007,7 +3007,7 @@ void sqlsrv_stream_dtor( _Inout_ zval* data ) void adjustDecimalPrecision(_Inout_ zval* param_z, _In_ SQLSMALLINT decimal_digits) { char* value = Z_STRVAL_P(param_z); - short value_len = Z_STRLEN_P(param_z); + int value_len = Z_STRLEN_P(param_z); // If the length is greater than maxDecimalStrLen, do not convert the string // 6 is derived from: 1 for the decimal point; 1 for sign of the number; 1 for 'e' or 'E' (scientific notation); @@ -3023,7 +3023,7 @@ void adjustDecimalPrecision(_Inout_ zval* param_z, _In_ SQLSMALLINT decimal_digi try { d = std::stold(std::string(value), &idx); } - catch (const std::logic_error& err) { + catch (const std::logic_error& ) { return; // invalid input caused the conversion to throw an exception } if (idx < value_len) { @@ -3047,15 +3047,15 @@ void adjustDecimalPrecision(_Inout_ zval* param_z, _In_ SQLSMALLINT decimal_digi char *pt = strchr(src, DECIMAL_POINT); char buffer[50] = " "; // A buffer with 2 blank spaces, as leeway - short offset = 1 + is_negative; // The position to start copying the original numerical value + int offset = 1 + is_negative; // The position to start copying the original numerical value if (exp == NULL) { if (pt == NULL) { return; // decimal point not found } - short src_length = strlen(src); - short num_decimals = src_length - (pt - src) - 1; + int src_length = strlen(src); + int num_decimals = src_length - (pt - src) - 1; if (num_decimals <= decimal_digits) { return; // no need to adjust number of decimals } @@ -3069,10 +3069,10 @@ void adjustDecimalPrecision(_Inout_ zval* param_z, _In_ SQLSMALLINT decimal_digi return; // Out of range, so let the server handle this } - short num_decimals = 0; + int num_decimals = 0; if (power == 0) { // Simply chop off the exp part - short length = (exp - src); + int length = (exp - src); memcpy_s(buffer + offset, length, src, length); if (pt != NULL) { @@ -3083,7 +3083,7 @@ void adjustDecimalPrecision(_Inout_ zval* param_z, _In_ SQLSMALLINT decimal_digi } } } else { - short oldpos = 0; + int oldpos = 0; if (pt == NULL) { oldpos = exp - src; // Decimal point not found, use the exp sign } @@ -3096,7 +3096,7 @@ void adjustDecimalPrecision(_Inout_ zval* param_z, _In_ SQLSMALLINT decimal_digi } // Derive the new position for the decimal point in the buffer - short newpos = oldpos + power; + int newpos = oldpos + power; if (power > 0) { newpos = newpos + offset; if (num_decimals == 0) { @@ -3125,8 +3125,8 @@ void adjustDecimalPrecision(_Inout_ zval* param_z, _In_ SQLSMALLINT decimal_digi // Start copying the content to the buffer until the exp sign or one more digit after decimal_digits char *p = src; - short idx = offset; - short lastpos = newpos + decimal_digits + 1; + int idx = offset; + int lastpos = newpos + decimal_digits + 1; while (p != exp && idx <= lastpos) { if (*p == DECIMAL_POINT) { p++; @@ -3156,14 +3156,14 @@ void adjustDecimalPrecision(_Inout_ zval* param_z, _In_ SQLSMALLINT decimal_digi ZVAL_NEW_STR(param_z, zstr); } -int round_up_decimal_numbers(_Inout_ char* buffer, _In_ short decimal_pos, _In_ short num_decimals, _In_ short offset, _In_ short lastpos) +int round_up_decimal_numbers(_Inout_ char* buffer, _In_ int decimal_pos, _In_ int num_decimals, _In_ int offset, _In_ int lastpos) { // This helper method assumes the 'buffer' has some extra blank spaces at the beginning without the minus '-' sign. // We want the rounding to be consistent with php number_format(), http://php.net/manual/en/function.number-format.php // as well as SQL Server Management studio, such that the least significant digit will be rounded up if it is // followed by 5 or above. - short pos = decimal_pos + num_decimals + 1; + int pos = decimal_pos + num_decimals + 1; if (pos < lastpos) { short n = buffer[pos] - '0'; if (n >= 5) { diff --git a/source/shared/localizationimpl.cpp b/source/shared/localizationimpl.cpp index 581e953f..ce850c81 100644 --- a/source/shared/localizationimpl.cpp +++ b/source/shared/localizationimpl.cpp @@ -469,7 +469,7 @@ size_t SystemLocale::Utf8To16( const char *src, SSIZE_T cchSrc, WCHAR *dest, siz } usrc++; ucode = (ucode&15)<<12 | (c1&0x3F)<<6 | (c2&0x3F); - if (ucode < 0x800 || ucode >= 0xD800 && ucode <= 0xDFFF) + if (ucode < 0x800 || (ucode >= 0xD800 && ucode <= 0xDFFF)) { goto Invalid; } @@ -511,7 +511,7 @@ size_t SystemLocale::Utf8To16( const char *src, SSIZE_T cchSrc, WCHAR *dest, siz if (ucode < 0x10000 // overlong encoding || ucode > 0x10FFFF // exceeds Unicode range - || ucode >= 0xD800 && ucode <= 0xDFFF) // surrogate pairs + || (ucode >= 0xD800 && ucode <= 0xDFFF)) // surrogate pairs { goto Invalid; } @@ -594,7 +594,7 @@ size_t SystemLocale::Utf8To16Strict( const char *src, SSIZE_T cchSrc, WCHAR *des } usrc++; ucode = (ucode&15)<<12 | (c1&0x3F)<<6 | (c2&0x3F); - if (ucode < 0x800 || ucode >= 0xD800 && ucode <= 0xDFFF) + if (ucode < 0x800 || (ucode >= 0xD800 && ucode <= 0xDFFF)) { goto Invalid; } @@ -636,7 +636,7 @@ size_t SystemLocale::Utf8To16Strict( const char *src, SSIZE_T cchSrc, WCHAR *des if (ucode < 0x10000 // overlong encoding || ucode > 0x10FFFF // exceeds Unicode range - || ucode >= 0xD800 && ucode <= 0xDFFF) // surrogate pairs + || (ucode >= 0xD800 && ucode <= 0xDFFF)) // surrogate pairs { goto Invalid; } @@ -794,7 +794,7 @@ size_t SystemLocale::Utf8From16( const WCHAR *src, SSIZE_T cchSrc, char *dest, s return 0; } *dest++ = 0xE0 | (wch >> 12); - *dest++ = 0x80 | (wch >> 6)&0x3F; + *dest++ = 0x80 | ((wch >> 6)&0x3F); *dest++ = 0x80 | (wch &0x3F); } else if (wch < 0xDC00) // 65536 to end of Unicode: 4 bytes @@ -832,9 +832,9 @@ size_t SystemLocale::Utf8From16( const WCHAR *src, SSIZE_T cchSrc, char *dest, s return 0; } *dest++ = 0xF0 | (wch >> 18); - *dest++ = 0x80 | (wch >>12)&0x3F; - *dest++ = 0x80 | (wch >> 6)&0x3F; - *dest++ = 0x80 | wch&0x3F; + *dest++ = 0x80 | ((wch >>12)&0x3F); + *dest++ = 0x80 | ((wch >> 6)&0x3F); + *dest++ = 0x80 | (wch&0x3F); } else // unexpected trail surrogate { @@ -933,7 +933,7 @@ size_t SystemLocale::Utf8From16Strict( const WCHAR *src, SSIZE_T cchSrc, char *d return 0; } *dest++ = 0xE0 | (wch >> 12); - *dest++ = 0x80 | (wch >> 6)&0x3F; + *dest++ = 0x80 | ((wch >> 6)&0x3F); *dest++ = 0x80 | (wch &0x3F); } else if (wch < 0xDC00) // 65536 to end of Unicode: 4 bytes @@ -964,9 +964,9 @@ size_t SystemLocale::Utf8From16Strict( const WCHAR *src, SSIZE_T cchSrc, char *d return 0; } *dest++ = 0xF0 | (wch >> 18); - *dest++ = 0x80 | (wch >>12)&0x3F; - *dest++ = 0x80 | (wch >> 6)&0x3F; - *dest++ = 0x80 | wch&0x3F; + *dest++ = 0x80 | ((wch >>12)&0x3F); + *dest++ = 0x80 | ((wch >> 6)&0x3F); + *dest++ = 0x80 | (wch&0x3F); } else // unexpected trail surrogate { diff --git a/source/sqlsrv/conn.cpp b/source/sqlsrv/conn.cpp index 129312d7..0c2680cb 100644 --- a/source/sqlsrv/conn.cpp +++ b/source/sqlsrv/conn.cpp @@ -1393,7 +1393,10 @@ int get_conn_option_key( _Inout_ sqlsrv_context& ctx, _In_ zend_string* key, _In break; } - } + case CONN_ATTR_INVALID: + SQLSRV_ASSERT(false, "Should not have reached CONN_ATTR_INVALID."); + break; + } return SS_CONN_OPTS[i].conn_option_key; } diff --git a/source/sqlsrv/init.cpp b/source/sqlsrv/init.cpp index 4cc02597..ab8f282c 100644 --- a/source/sqlsrv/init.cpp +++ b/source/sqlsrv/init.cpp @@ -271,7 +271,7 @@ zend_module_entry g_sqlsrv_module_entry = PHP_MINIT_FUNCTION(sqlsrv) { - SQLSRV_UNUSED( type ); + // SQLSRV_UNUSED( type ); core_sqlsrv_register_severity_checker(ss_severity_check); @@ -596,7 +596,7 @@ void sqlsrv_encoding_dtor( _Inout_ zval* elem ) { PHP_MSHUTDOWN_FUNCTION(sqlsrv) { - SQLSRV_UNUSED( type ); + // SQLSRV_UNUSED( type ); UNREGISTER_INI_ENTRIES(); @@ -630,8 +630,8 @@ PHP_MSHUTDOWN_FUNCTION(sqlsrv) PHP_RINIT_FUNCTION(sqlsrv) { - SQLSRV_UNUSED( module_number ); - SQLSRV_UNUSED( type ); + // SQLSRV_UNUSED( module_number ); + // SQLSRV_UNUSED( type ); #if defined(ZTS) ZEND_TSRMLS_CACHE_UPDATE(); @@ -690,8 +690,8 @@ PHP_RINIT_FUNCTION(sqlsrv) PHP_RSHUTDOWN_FUNCTION(sqlsrv) { - SQLSRV_UNUSED( module_number ); - SQLSRV_UNUSED( type ); + // SQLSRV_UNUSED( module_number ); + // SQLSRV_UNUSED( type ); LOG_FUNCTION( "PHP_RSHUTDOWN for php_sqlsrv" ); reset_errors(); diff --git a/source/sqlsrv/php_sqlsrv_int.h b/source/sqlsrv/php_sqlsrv_int.h index 87a15c20..e849b758 100644 --- a/source/sqlsrv/php_sqlsrv_int.h +++ b/source/sqlsrv/php_sqlsrv_int.h @@ -212,7 +212,7 @@ enum SS_ERROR_CODES { extern ss_error SS_ERRORS[]; -bool ss_error_handler( _Inout_ sqlsrv_context& ctx, _In_ unsigned int sqlsrv_error_code, _In_ bool warning, _In_opt_ va_list* print_args ); +bool ss_error_handler( _Inout_ sqlsrv_context& ctx, _In_ unsigned int sqlsrv_error_code, _In_ int warning, _In_opt_ va_list* print_args ); // convert from the default encoding specified by the "CharacterSet" // connection option to UTF-16. mbcs_len and utf16_len are sizes in @@ -258,7 +258,7 @@ inline void reset_errors( void ) } #define THROW_SS_ERROR( ctx, error_code, ... ) \ - (void)call_error_handler( ctx, error_code, false /*warning*/, ## __VA_ARGS__ ); \ + (void)call_error_handler( ctx, error_code, 0 /*warning*/, ## __VA_ARGS__ ); \ throw ss::SSException(); @@ -360,7 +360,7 @@ namespace ss { template inline H* process_params( INTERNAL_FUNCTION_PARAMETERS, _In_ char const* param_spec, _In_ const char* calling_func, _In_ size_t param_count, ... ) { - SQLSRV_UNUSED( return_value ); + // SQLSRV_UNUSED( return_value ); zval* rsrc; H* h = NULL; diff --git a/source/sqlsrv/util.cpp b/source/sqlsrv/util.cpp index d956c457..0575ab28 100644 --- a/source/sqlsrv/util.cpp +++ b/source/sqlsrv/util.cpp @@ -37,7 +37,7 @@ void copy_error_to_zval( _Inout_ zval* error_z, _In_ sqlsrv_error_const* error, _In_ bool warning ); bool ignore_warning( _In_ char* sql_state, _In_ int native_code ); bool handle_errors_and_warnings( _Inout_ sqlsrv_context& ctx, _Inout_ zval* reported_chain, _Inout_ zval* ignored_chain, _In_ logging_severity log_severity, - _In_ unsigned int sqlsrv_error_code, _In_ bool warning, _In_opt_ va_list* print_args ); + _In_ unsigned int sqlsrv_error_code, _In_ int warning, _In_opt_ va_list* print_args ); int sqlsrv_merge_zend_hash_dtor( _Inout_ zval* dest ); bool sqlsrv_merge_zend_hash( _Inout_ zval* dest_z, zval const* src_z ); @@ -456,7 +456,7 @@ bool ss_severity_check(_In_ unsigned int severity) return ((severity & SQLSRV_G(log_severity)) && (SQLSRV_G(current_subsystem) & SQLSRV_G(log_subsystems))); } -bool ss_error_handler( _Inout_ sqlsrv_context& ctx, _In_ unsigned int sqlsrv_error_code, _In_ bool warning, _In_opt_ va_list* print_args ) +bool ss_error_handler( _Inout_ sqlsrv_context& ctx, _In_ unsigned int sqlsrv_error_code, _In_ int warning, _In_opt_ va_list* print_args ) { logging_severity severity = SEV_ERROR; if( warning && !SQLSRV_G( warnings_return_as_errors )) { @@ -506,7 +506,7 @@ bool ss_error_handler( _Inout_ sqlsrv_context& ctx, _In_ unsigned int sqlsrv_err PHP_FUNCTION( sqlsrv_errors ) { - SQLSRV_UNUSED( execute_data ); + // SQLSRV_UNUSED( execute_data ); zend_long flags = SQLSRV_ERR_ALL; @@ -557,7 +557,7 @@ PHP_FUNCTION( sqlsrv_errors ) PHP_FUNCTION( sqlsrv_configure ) { - SQLSRV_UNUSED( execute_data ); + // SQLSRV_UNUSED( execute_data ); LOG_FUNCTION( "sqlsrv_configure" ); @@ -680,7 +680,7 @@ PHP_FUNCTION( sqlsrv_configure ) PHP_FUNCTION( sqlsrv_get_config ) { - SQLSRV_UNUSED( execute_data ); + // SQLSRV_UNUSED( execute_data ); char* option = NULL; size_t option_len; @@ -821,7 +821,7 @@ void copy_error_to_zval( _Inout_ zval* error_z, _In_ sqlsrv_error_const* error, } bool handle_errors_and_warnings( _Inout_ sqlsrv_context& ctx, _Inout_ zval* reported_chain, _Inout_ zval* ignored_chain, _In_ logging_severity log_severity, - _In_ unsigned int sqlsrv_error_code, _In_ bool warning, _In_opt_ va_list* print_args ) + _In_ unsigned int sqlsrv_error_code, _In_ int warning, _In_opt_ va_list* print_args ) { bool result = true; bool errors_ignored = false;