mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Solve C4267 warnings in win32/ioutil for x64 (GH-17674)
C4267[1] are about conversion from `size_t` to a "smaller" type, causing potential loss of data (aka. truncation). In this case we can solve that cleanly (i.e. without casting and further checks) by changing the affected variables to be of type `DWORD`. [1] <https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4267>
This commit is contained in:
parent
6ae12093ce
commit
caf5e8a167
2 changed files with 7 additions and 5 deletions
|
@ -281,7 +281,8 @@ PW32IO int php_win32_ioutil_close(int fd)
|
|||
|
||||
PW32IO int php_win32_ioutil_mkdir_w(const wchar_t *path, mode_t mode)
|
||||
{/*{{{*/
|
||||
size_t path_len, dir_len = 0;
|
||||
size_t path_len;
|
||||
DWORD dir_len = 0;
|
||||
const wchar_t *my_path;
|
||||
|
||||
if (!path) {
|
||||
|
@ -336,7 +337,7 @@ PW32IO int php_win32_ioutil_mkdir_w(const wchar_t *path, mode_t mode)
|
|||
dst = _tmp + PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW;
|
||||
#ifndef ZTS
|
||||
if (dir_len > 0) {
|
||||
size_t len = GetCurrentDirectoryW(dir_len, dst);
|
||||
DWORD len = GetCurrentDirectoryW(dir_len, dst);
|
||||
if (len == 0 || len + 1 != dir_len) {
|
||||
free(tmp);
|
||||
free(_tmp);
|
||||
|
|
|
@ -175,7 +175,8 @@ PW32IO php_win32_ioutil_normalization_result php_win32_ioutil_normalize_path_w(w
|
|||
zend_always_inline static wchar_t *php_win32_ioutil_conv_any_to_w(const char* in, size_t in_len, size_t *out_len)
|
||||
{/*{{{*/
|
||||
wchar_t *mb, *ret;
|
||||
size_t mb_len, dir_len = 0;
|
||||
size_t mb_len;
|
||||
DWORD dir_len = 0;
|
||||
|
||||
mb = php_win32_cp_conv_any_to_w(in, in_len, &mb_len);
|
||||
if (!mb) {
|
||||
|
@ -227,8 +228,8 @@ zend_always_inline static wchar_t *php_win32_ioutil_conv_any_to_w(const char* in
|
|||
memcpy(ret, PHP_WIN32_IOUTIL_LONG_PATH_PREFIXW, PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW * sizeof(wchar_t));
|
||||
#ifndef ZTS
|
||||
if (dir_len > 0) {
|
||||
size_t len = GetCurrentDirectoryW(dir_len, dst);
|
||||
if (len == 0 || len + 1 != dir_len) {
|
||||
DWORD len = GetCurrentDirectoryW(dir_len, dst);
|
||||
if (len == 0 || len != dir_len - 1) {
|
||||
free(ret);
|
||||
free(mb);
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue