Skip to content

Commit 84079f4

Browse files
committed
cleanup casts
1 parent e403acc commit 84079f4

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

main/php_open_temporary_file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, zend_st
114114
}
115115

116116
#ifdef PHP_WIN32
117-
if (!php_win32_check_trailing_space(pfx, (const int)strlen(pfx))) {
117+
if (!php_win32_check_trailing_space(pfx, strlen(pfx))) {
118118
SetLastError(ERROR_INVALID_NAME);
119119
return -1;
120120
}

main/streams/plain_wrapper.c

+4-7
Original file line numberDiff line numberDiff line change
@@ -1139,11 +1139,11 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
11391139
}
11401140

11411141
#ifdef PHP_WIN32
1142-
if (!php_win32_check_trailing_space(url_from, (int)strlen(url_from))) {
1142+
if (!php_win32_check_trailing_space(url_from, strlen(url_from))) {
11431143
php_win32_docref2_from_error(ERROR_INVALID_NAME, url_from, url_to);
11441144
return 0;
11451145
}
1146-
if (!php_win32_check_trailing_space(url_to, (int)strlen(url_to))) {
1146+
if (!php_win32_check_trailing_space(url_to, strlen(url_to))) {
11471147
php_win32_docref2_from_error(ERROR_INVALID_NAME, url_from, url_to);
11481148
return 0;
11491149
}
@@ -1311,7 +1311,7 @@ static int php_plain_files_rmdir(php_stream_wrapper *wrapper, const char *url, i
13111311
}
13121312

13131313
#ifdef PHP_WIN32
1314-
if (!php_win32_check_trailing_space(url, (int)strlen(url))) {
1314+
if (!php_win32_check_trailing_space(url, strlen(url))) {
13151315
php_error_docref1(NULL, url, E_WARNING, "%s", strerror(ENOENT));
13161316
return 0;
13171317
}
@@ -1337,12 +1337,9 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
13371337
#endif
13381338
mode_t mode;
13391339
int ret = 0;
1340-
#ifdef PHP_WIN32
1341-
int url_len = (int)strlen(url);
1342-
#endif
13431340

13441341
#ifdef PHP_WIN32
1345-
if (!php_win32_check_trailing_space(url, url_len)) {
1342+
if (!php_win32_check_trailing_space(url, strlen(url))) {
13461343
php_error_docref1(NULL, url, E_WARNING, "%s", strerror(ENOENT));
13471344
return 0;
13481345
}

win32/winutil.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ PHP_WINUTIL_API char *php_win32_error_to_msg(HRESULT error)
3636
return (buf ? (char *) buf : "");
3737
}/*}}}*/
3838

39-
int php_win32_check_trailing_space(const char * path, const int path_len)
39+
int php_win32_check_trailing_space(const char * path, const size_t path_len)
4040
{/*{{{*/
41-
if (path_len < 1) {
41+
if (path_len > MAXPATHLEN - 1) {
4242
return 1;
4343
}
4444
if (path) {

win32/winutil.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
PHP_WINUTIL_API char *php_win32_error_to_msg(HRESULT error);
2929

3030
#define php_win_err() php_win32_error_to_msg(GetLastError())
31-
int php_win32_check_trailing_space(const char * path, const int path_len);
31+
int php_win32_check_trailing_space(const char * path, const size_t path_len);
3232
PHP_WINUTIL_API int php_win32_get_random_bytes(unsigned char *buf, size_t size);
3333
#ifdef PHP_EXPORTS
3434
BOOL php_win32_init_random_bytes(void);

0 commit comments

Comments
 (0)