Skip to content

Commit 6f63d4b

Browse files
committed
Fix -Wenum-int-mismatch warnings on gcc 13
Closes phpGH-11103
1 parent 04fd04a commit 6f63d4b

14 files changed

+38
-22
lines changed

UPGRADING.INTERNALS

+15
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ PHP 8.3 INTERNALS UPGRADE NOTES
5151
variable value. This avoids side-effects through destructors between the
5252
assignment of the variable and the assignment to the result zval in the VM
5353
(i.e. it may free the new value). See GH-10168 for details.
54+
* The return types of the following functions were changed from int to
55+
zend_result:
56+
- open_file_for_scanning
57+
- php_rfc1867_callback
58+
- virtual_chdir
59+
- zend_execute_scripts
60+
- zend_get_module_started
61+
- zend_handle_undef_args
62+
- zend_list_delete
63+
- zend_multibyte_parse_encoding_list
64+
- zend_multibyte_set_internal_encoding
65+
- zend_parse_ini_file
66+
- zend_parse_ini_string
67+
- zend_set_user_opcode_handler
68+
- zend_ssa_inference
5469

5570
========================
5671
2. Build system changes

Zend/Optimizer/zend_inference.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ BEGIN_EXTERN_C()
220220

221221
ZEND_API void zend_ssa_find_false_dependencies(const zend_op_array *op_array, zend_ssa *ssa);
222222
ZEND_API void zend_ssa_find_sccs(const zend_op_array *op_array, zend_ssa *ssa);
223-
ZEND_API int zend_ssa_inference(zend_arena **raena, const zend_op_array *op_array, const zend_script *script, zend_ssa *ssa, zend_long optimization_level);
223+
ZEND_API zend_result zend_ssa_inference(zend_arena **raena, const zend_op_array *op_array, const zend_script *script, zend_ssa *ssa, zend_long optimization_level);
224224

225225
ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, int write, int insert);
226226

Zend/zend_API.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ ZEND_API bool zend_is_callable_ex(zval *callable, zend_object *object, uint32_t
416416
ZEND_API bool zend_is_callable(zval *callable, uint32_t check_flags, zend_string **callable_name);
417417
ZEND_API bool zend_make_callable(zval *callable, zend_string **callable_name);
418418
ZEND_API const char *zend_get_module_version(const char *module_name);
419-
ZEND_API int zend_get_module_started(const char *module_name);
419+
ZEND_API zend_result zend_get_module_started(const char *module_name);
420420

421421
ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment, zend_type type);
422422

Zend/zend_compile.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,8 @@ ZEND_API zend_op_array *compile_string(zend_string *source_string, const char *f
851851
ZEND_API zend_op_array *compile_filename(int type, zend_string *filename);
852852
ZEND_API zend_ast *zend_compile_string_to_ast(
853853
zend_string *code, struct _zend_arena **ast_arena, zend_string *filename);
854-
ZEND_API int zend_execute_scripts(int type, zval *retval, int file_count, ...);
855-
ZEND_API int open_file_for_scanning(zend_file_handle *file_handle);
854+
ZEND_API zend_result zend_execute_scripts(int type, zval *retval, int file_count, ...);
855+
ZEND_API zend_result open_file_for_scanning(zend_file_handle *file_handle);
856856
ZEND_API void init_op_array(zend_op_array *op_array, uint8_t type, int initial_ops_size);
857857
ZEND_API void destroy_op_array(zend_op_array *op_array);
858858
ZEND_API void zend_destroy_static_vars(zend_op_array *op_array);

Zend/zend_execute.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ ZEND_API bool zend_gcc_global_regs(void);
404404

405405
#define ZEND_USER_OPCODE_DISPATCH_TO 0x100 /* call original handler of returned opcode */
406406

407-
ZEND_API int zend_set_user_opcode_handler(uint8_t opcode, user_opcode_handler_t handler);
407+
ZEND_API zend_result zend_set_user_opcode_handler(uint8_t opcode, user_opcode_handler_t handler);
408408
ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(uint8_t opcode);
409409

410410
ZEND_API zval *zend_get_zval_ptr(const zend_op *opline, int op_type, const znode_op *node, const zend_execute_data *execute_data);
@@ -419,7 +419,7 @@ ZEND_API HashTable *zend_unfinished_execution_gc_ex(zend_execute_data *execute_d
419419
zval * ZEND_FASTCALL zend_handle_named_arg(
420420
zend_execute_data **call_ptr, zend_string *arg_name,
421421
uint32_t *arg_num_ptr, void **cache_slot);
422-
ZEND_API int ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call);
422+
ZEND_API zend_result ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call);
423423

424424
#define CACHE_ADDR(num) \
425425
((void**)((char*)EX(run_time_cache) + (num)))

Zend/zend_ini.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ END_EXTERN_C()
234234
/* INI parsing engine */
235235
typedef void (*zend_ini_parser_cb_t)(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg);
236236
BEGIN_EXTERN_C()
237-
ZEND_API int zend_parse_ini_file(zend_file_handle *fh, bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg);
238-
ZEND_API int zend_parse_ini_string(const char *str, bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg);
237+
ZEND_API zend_result zend_parse_ini_file(zend_file_handle *fh, bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg);
238+
ZEND_API zend_result zend_parse_ini_string(const char *str, bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg);
239239
END_EXTERN_C()
240240

241241
/* INI entries */

Zend/zend_interfaces.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static void zend_user_it_dtor(zend_object_iterator *_iter)
118118
/* }}} */
119119

120120
/* {{{ zend_user_it_valid */
121-
ZEND_API int zend_user_it_valid(zend_object_iterator *_iter)
121+
ZEND_API zend_result zend_user_it_valid(zend_object_iterator *_iter)
122122
{
123123
if (_iter) {
124124
zend_user_iterator *iter = (zend_user_iterator*)_iter;
@@ -198,7 +198,8 @@ ZEND_API HashTable *zend_user_it_get_gc(zend_object_iterator *_iter, zval **tabl
198198

199199
static const zend_object_iterator_funcs zend_interface_iterator_funcs_iterator = {
200200
zend_user_it_dtor,
201-
zend_user_it_valid,
201+
// FIXME: Adjust the actual function prototype in zend_object_iterator_funcs
202+
(int (*)(zend_object_iterator *)) zend_user_it_valid,
202203
zend_user_it_get_current_data,
203204
zend_user_it_get_current_key,
204205
zend_user_it_move_forward,

Zend/zend_list.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void zend_destroy_rsrc_list_dtors(void);
5454

5555
ZEND_API zval* ZEND_FASTCALL zend_list_insert(void *ptr, int type);
5656
ZEND_API void ZEND_FASTCALL zend_list_free(zend_resource *res);
57-
ZEND_API int ZEND_FASTCALL zend_list_delete(zend_resource *res);
57+
ZEND_API zend_result ZEND_FASTCALL zend_list_delete(zend_resource *res);
5858
ZEND_API void ZEND_FASTCALL zend_list_close(zend_resource *res);
5959

6060
ZEND_API zend_resource *zend_register_resource(void *rsrc_pointer, int rsrc_type);

Zend/zend_multibyte.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ ZEND_API const char *zend_multibyte_get_encoding_name(const zend_encoding *encod
6666
ZEND_API int zend_multibyte_check_lexer_compatibility(const zend_encoding *encoding);
6767
ZEND_API const zend_encoding *zend_multibyte_encoding_detector(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size);
6868
ZEND_API size_t zend_multibyte_encoding_converter(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from);
69-
ZEND_API int zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent);
69+
ZEND_API zend_result zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent);
7070

7171
ZEND_API const zend_encoding *zend_multibyte_get_internal_encoding(void);
7272
ZEND_API const zend_encoding *zend_multibyte_get_script_encoding(void);
7373
ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size);
74-
ZEND_API int zend_multibyte_set_internal_encoding(const zend_encoding *encoding);
74+
ZEND_API zend_result zend_multibyte_set_internal_encoding(const zend_encoding *encoding);
7575
ZEND_API zend_result zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length);
7676

7777
END_EXTERN_C()

Zend/zend_signal.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ ZEND_API zend_signal_globals_t zend_signal_globals;
6262
#endif
6363

6464
static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context);
65-
static int zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*));
65+
static zend_result zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*));
6666

6767
#if defined(__CYGWIN__) || defined(__PASE__)
6868
/* Matches zend_execute_API.c; these platforms don't support ITIMER_PROF. */

Zend/zend_virtual_cwd.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ CWD_API int virtual_cwd_activate(void);
160160
CWD_API int virtual_cwd_deactivate(void);
161161
CWD_API char *virtual_getcwd_ex(size_t *length);
162162
CWD_API char *virtual_getcwd(char *buf, size_t size);
163-
CWD_API int virtual_chdir(const char *path);
163+
CWD_API zend_result virtual_chdir(const char *path);
164164
CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path));
165165
CWD_API int virtual_filepath(const char *path, char **filepath);
166166
CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path);
@@ -260,7 +260,7 @@ extern void virtual_cwd_main_cwd_init(uint8_t);
260260
#define VCWD_OPEN_MODE(path, flags, mode) virtual_open(path, flags, mode)
261261
#define VCWD_CREAT(path, mode) virtual_creat(path, mode)
262262
#define VCWD_CHDIR(path) virtual_chdir(path)
263-
#define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, virtual_chdir)
263+
#define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, (int (*)(const char *)) virtual_chdir)
264264
#define VCWD_GETWD(buf)
265265
#define VCWD_REALPATH(path, real_path) virtual_realpath(path, real_path)
266266
#define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname)

ext/session/session.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656

5757
PHPAPI ZEND_DECLARE_MODULE_GLOBALS(ps)
5858

59-
static int php_session_rfc1867_callback(unsigned int event, void *event_data, void **extra);
60-
static int (*php_session_rfc1867_orig_callback)(unsigned int event, void *event_data, void **extra);
59+
static zend_result php_session_rfc1867_callback(unsigned int event, void *event_data, void **extra);
60+
static zend_result (*php_session_rfc1867_orig_callback)(unsigned int event, void *event_data, void **extra);
6161
static void php_session_track_init(void);
6262

6363
/* SessionHandler class */
@@ -97,8 +97,8 @@ zend_class_entry *php_session_update_timestamp_iface_entry;
9797

9898
#define APPLY_TRANS_SID (PS(use_trans_sid) && !PS(use_only_cookies))
9999

100-
static int php_session_send_cookie(void);
101-
static int php_session_abort(void);
100+
static zend_result php_session_send_cookie(void);
101+
static zend_result php_session_abort(void);
102102

103103
/* Initialized in MINIT, readonly otherwise. */
104104
static int my_module_number = 0;

main/rfc1867.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static php_rfc1867_getword_t php_rfc1867_getword = php_ap_getword;
4949
static php_rfc1867_getword_conf_t php_rfc1867_getword_conf = php_ap_getword_conf;
5050
static php_rfc1867_basename_t php_rfc1867_basename = NULL;
5151

52-
PHPAPI int (*php_rfc1867_callback)(unsigned int event, void *event_data, void **extra) = NULL;
52+
PHPAPI zend_result (*php_rfc1867_callback)(unsigned int event, void *event_data, void **extra) = NULL;
5353

5454
static void safe_php_register_variable(char *var, char *strval, size_t val_len, zval *track_vars_array, bool override_protection);
5555

main/rfc1867.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ typedef char* (*php_rfc1867_basename_t)(const zend_encoding *encoding, char *str
8383
SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler);
8484

8585
PHPAPI void destroy_uploaded_files_hash(void);
86-
extern PHPAPI int (*php_rfc1867_callback)(unsigned int event, void *event_data, void **extra);
86+
extern PHPAPI zend_result (*php_rfc1867_callback)(unsigned int event, void *event_data, void **extra);
8787

8888
SAPI_API void php_rfc1867_set_multibyte_callbacks(
8989
php_rfc1867_encoding_translation_t encoding_translation,

0 commit comments

Comments
 (0)