Commit c4fc9c7
authored
Fix x86 C4389 signed/unsigned mismatch in pdo_stmt.cpp (#1577)
* FIX: Resolve C4146 compiler warning for SDL compliance
- Changed unsigned long cursor_type initialization from -1 to ULONG_MAX in stmt.cpp
- Removed /wd4146 warning suppression from sqlsrv and pdo_sqlsrv config.w32 files
- C4146 is a mandatory SDL warning that must not be suppressed
* Suppress PHP 8.5 header warnings (C4146, C4244) on Windows
* SDL compliance: Enable /W4 /WX and fix mandatory warnings C4244/C4267
* SDL compliance: Fix W4/WX warnings across all source files
- core_sqlsrv.h: Suppress PHP header warnings, fix C4100 unreferenced params
- core_stmt.cpp: Fix C4244, C4267, C4100, C4458, C4245, C4127, C4189
- core_util.cpp: Fix C4244, C4100 (record_number type, UCHAR casts)
- core_results.cpp: Fix C4245, C4100, C4239
- core_conn.cpp: Fix C4245 signed/unsigned mismatch
- conn.cpp, stmt.cpp, util.cpp (sqlsrv): Fix C4245 signed/unsigned
- pdo_dbh.cpp: Fix C4245 signed/unsigned mismatch
* SDL compliance: Fix remaining W4/WX warnings across shared source files
- core_sqlsrv.h: Fix CHECK_SQL_ERROR_OR_WARNING macro to use __COUNTER__ for
unique variable names, preventing C4456 variable shadowing
- core_conn.cpp: Fix C4189 (unused version variable), C4100 (unreferenced
params: is_pooled, conn, driver, key_size, option, conn_str), C4244/C4267
(narrowing casts for SQLDescribeParam, dataSize, transform/tolower lambda)
- core_results.cpp: Fix C4245 signed/unsigned in constructor initializer list
- core_stmt.cpp: Fix C4244 (casts for core_sqlsrv_get_field, is_a_numeric_type,
numzeroes, round_up types, tvp_columns key), C4100 (conn in get_stmt_option)
* SDL compliance: Fix __COUNTER__ macro expansion and C4701 uninitialized var
- core_sqlsrv.h: Add 3-level macro indirection for CHECK_SQL_ERROR_OR_WARNING
so __COUNTER__ expands before ## token pasting under /Zc:preprocessor
(matches existing CHECK_ERROR/CHECK_ERROR_UNIQUE/CHECK_ERROR_EX pattern)
- core_conn.cpp: Initialize SQLRETURN r = SQL_SUCCESS to fix C4701
- core_stmt.cpp: Comment out unused conn param in get_stmt_option (C4100)
* SDL compliance: Fix driver-specific W4/WX warnings and PHP header suppression
- php_sqlsrv.h, php_pdo_sqlsrv.h: Add pragma warning suppression around
#include php.h to fix zend_gc.h C4244, zend_ast.h C4244, zend_hash.h C4127
- core_sqlsrv.h: Fix SQLSRV_UNUSED macro to use (void)(var) for proper C4100
suppression
- php_sqlsrv_int.h: Uncomment SQLSRV_UNUSED(return_value) in process_params
template to fix C4100
- sqlsrv/stmt.cpp: Fix C4245 conn_index initializer, C4100 unused stmt param,
C4267/C4244 size_t/int narrowing in get_resultset_meta_data, C4244 in
fetch_fields_common, wrap RETURN_ZVAL with pragma for C4127
- sqlsrv/conn.cpp: Fix tolower C4244 with lambda
- sqlsrv/util.cpp: Wrap RETURN_ZVAL with pragma for C4127
- sqlsrv/init.cpp: Uncomment SQLSRV_UNUSED for type/module_number in all PHP
lifecycle functions to fix C4100
- pdo_sqlsrv/pdo_init.cpp: Same SQLSRV_UNUSED fixes for pdo lifecycle functions
- pdo_sqlsrv/pdo_dbh.cpp: Fix tolower C4244 with lambda
* Fix C4100: comment out unused stmt param in determine_column_size_or_precision
* Fix /W4 /WX warnings in pdo_sqlsrv driver files
pdo_dbh.cpp:
- C4244: cast pdo_error_mode to decltype(dbh->error_mode) for PHP 8.5 uint8_t
- C4189: wrap sql_rewrite_len in #if PHP_VERSION_ID < 80100 (unused in >= 8.1)
- C4267: cast ZSTR_LEN to int for sql_string_parser ctor and core_sqlsrv_execute
- C4189: suppress unused execReturn with (void)
- C4100: comment out unused 'kind' parameter in pdo_sqlsrv_get_driver_methods
- C4390: add empty block {} after CHECK_CUSTOM_WARNING_AS_ERROR macro call
- C4245: cast -1 to size_t for int_key initialization
pdo_parser.cpp + php_pdo_sqlsrv_int.h:
- C4458: rename 'len' param to 'buf_len'/'val_len' to avoid shadowing class member
- C4389: cast new_len to size_t for signed/unsigned comparison
pdo_stmt.cpp:
- C4244: cast colno to SQLSMALLINT/SQLUSMALLINT for core_sqlsrv_field_metadata
and core_sqlsrv_get_field calls
- C4267: cast ZSTR_LEN to unsigned int for query_len
- C4244: cast stmt->column_count (int) to short for driver_stmt->column_count
- C4244: cast stmt->row_count (zend_long) to long for driver_stmt->row_count
- C4100: comment out unused 'type', 'size', 'prefer_string_over_stream' params
- C4018: cast colno to size_t for comparison with vector::size()
- C4244: cast direction to SQLSMALLINT for core_sqlsrv_bind_param
pdo_util.cpp:
- C4244: change rec_number type from unsigned int to SQLSMALLINT
* Fix C4018/C4389 signed/unsigned mismatches in core_stmt.cpp for x86 builds
- Cast value_len to size_t for comparison with std::stold index
- Change num_columns from int to size_t to match total_num_columns
* Fix C4267: keep num_columns as int, cast at comparison and assignment
Reverting num_columns to int (matching function return type) and casting
zend_hash_num_elements result to int at assignment, plus casting to size_t
at the comparison with total_num_columns to fix both C4389 and C4267.
* Fix C4389: cast colno+1 to size_t for x86 signed/unsigned comparison in pdo_stmt.cpp1 parent 1d8f1a6 commit c4fc9c7
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
469 | | - | |
| 469 | + | |
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
| |||
0 commit comments