From 6f63d4b274f51b792ccfac98bde47e7b4df522e3 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Wed, 19 Apr 2023 16:59:20 +0200 Subject: [PATCH] Fix -Wenum-int-mismatch warnings on gcc 13 Closes GH-11103 --- UPGRADING.INTERNALS | 15 +++++++++++++++ Zend/Optimizer/zend_inference.h | 2 +- Zend/zend_API.h | 2 +- Zend/zend_compile.h | 4 ++-- Zend/zend_execute.h | 4 ++-- Zend/zend_ini.h | 4 ++-- Zend/zend_interfaces.c | 5 +++-- Zend/zend_list.h | 2 +- Zend/zend_multibyte.h | 4 ++-- Zend/zend_signal.c | 2 +- Zend/zend_virtual_cwd.h | 4 ++-- ext/session/session.c | 8 ++++---- main/rfc1867.c | 2 +- main/rfc1867.h | 2 +- 14 files changed, 38 insertions(+), 22 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index eecbf26747a..1309cb34ac6 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -51,6 +51,21 @@ PHP 8.3 INTERNALS UPGRADE NOTES variable value. This avoids side-effects through destructors between the assignment of the variable and the assignment to the result zval in the VM (i.e. it may free the new value). See GH-10168 for details. +* The return types of the following functions were changed from int to + zend_result: + - open_file_for_scanning + - php_rfc1867_callback + - virtual_chdir + - zend_execute_scripts + - zend_get_module_started + - zend_handle_undef_args + - zend_list_delete + - zend_multibyte_parse_encoding_list + - zend_multibyte_set_internal_encoding + - zend_parse_ini_file + - zend_parse_ini_string + - zend_set_user_opcode_handler + - zend_ssa_inference ======================== 2. Build system changes diff --git a/Zend/Optimizer/zend_inference.h b/Zend/Optimizer/zend_inference.h index 22668001979..4e768c4f6d5 100644 --- a/Zend/Optimizer/zend_inference.h +++ b/Zend/Optimizer/zend_inference.h @@ -220,7 +220,7 @@ BEGIN_EXTERN_C() ZEND_API void zend_ssa_find_false_dependencies(const zend_op_array *op_array, zend_ssa *ssa); ZEND_API void zend_ssa_find_sccs(const zend_op_array *op_array, zend_ssa *ssa); -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); +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); ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, int write, int insert); diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 9c1cf08aa78..7c13c5e860b 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -416,7 +416,7 @@ ZEND_API bool zend_is_callable_ex(zval *callable, zend_object *object, uint32_t ZEND_API bool zend_is_callable(zval *callable, uint32_t check_flags, zend_string **callable_name); ZEND_API bool zend_make_callable(zval *callable, zend_string **callable_name); ZEND_API const char *zend_get_module_version(const char *module_name); -ZEND_API int zend_get_module_started(const char *module_name); +ZEND_API zend_result zend_get_module_started(const char *module_name); 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); diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 0ef351ab274..d474d13e86d 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -851,8 +851,8 @@ ZEND_API zend_op_array *compile_string(zend_string *source_string, const char *f ZEND_API zend_op_array *compile_filename(int type, zend_string *filename); ZEND_API zend_ast *zend_compile_string_to_ast( zend_string *code, struct _zend_arena **ast_arena, zend_string *filename); -ZEND_API int zend_execute_scripts(int type, zval *retval, int file_count, ...); -ZEND_API int open_file_for_scanning(zend_file_handle *file_handle); +ZEND_API zend_result zend_execute_scripts(int type, zval *retval, int file_count, ...); +ZEND_API zend_result open_file_for_scanning(zend_file_handle *file_handle); ZEND_API void init_op_array(zend_op_array *op_array, uint8_t type, int initial_ops_size); ZEND_API void destroy_op_array(zend_op_array *op_array); ZEND_API void zend_destroy_static_vars(zend_op_array *op_array); diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 594561da1bb..dab902c383c 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -404,7 +404,7 @@ ZEND_API bool zend_gcc_global_regs(void); #define ZEND_USER_OPCODE_DISPATCH_TO 0x100 /* call original handler of returned opcode */ -ZEND_API int zend_set_user_opcode_handler(uint8_t opcode, user_opcode_handler_t handler); +ZEND_API zend_result zend_set_user_opcode_handler(uint8_t opcode, user_opcode_handler_t handler); ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(uint8_t opcode); 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 zval * ZEND_FASTCALL zend_handle_named_arg( zend_execute_data **call_ptr, zend_string *arg_name, uint32_t *arg_num_ptr, void **cache_slot); -ZEND_API int ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call); +ZEND_API zend_result ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call); #define CACHE_ADDR(num) \ ((void**)((char*)EX(run_time_cache) + (num))) diff --git a/Zend/zend_ini.h b/Zend/zend_ini.h index 16189538353..6ca5658e970 100644 --- a/Zend/zend_ini.h +++ b/Zend/zend_ini.h @@ -234,8 +234,8 @@ END_EXTERN_C() /* INI parsing engine */ typedef void (*zend_ini_parser_cb_t)(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg); BEGIN_EXTERN_C() -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); -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); +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); +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); END_EXTERN_C() /* INI entries */ diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index d05310b737b..5d2f7d0ffc4 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -118,7 +118,7 @@ static void zend_user_it_dtor(zend_object_iterator *_iter) /* }}} */ /* {{{ zend_user_it_valid */ -ZEND_API int zend_user_it_valid(zend_object_iterator *_iter) +ZEND_API zend_result zend_user_it_valid(zend_object_iterator *_iter) { if (_iter) { 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 static const zend_object_iterator_funcs zend_interface_iterator_funcs_iterator = { zend_user_it_dtor, - zend_user_it_valid, + // FIXME: Adjust the actual function prototype in zend_object_iterator_funcs + (int (*)(zend_object_iterator *)) zend_user_it_valid, zend_user_it_get_current_data, zend_user_it_get_current_key, zend_user_it_move_forward, diff --git a/Zend/zend_list.h b/Zend/zend_list.h index 680915121e2..55ccf78dca1 100644 --- a/Zend/zend_list.h +++ b/Zend/zend_list.h @@ -54,7 +54,7 @@ void zend_destroy_rsrc_list_dtors(void); ZEND_API zval* ZEND_FASTCALL zend_list_insert(void *ptr, int type); ZEND_API void ZEND_FASTCALL zend_list_free(zend_resource *res); -ZEND_API int ZEND_FASTCALL zend_list_delete(zend_resource *res); +ZEND_API zend_result ZEND_FASTCALL zend_list_delete(zend_resource *res); ZEND_API void ZEND_FASTCALL zend_list_close(zend_resource *res); ZEND_API zend_resource *zend_register_resource(void *rsrc_pointer, int rsrc_type); diff --git a/Zend/zend_multibyte.h b/Zend/zend_multibyte.h index 5466840cd90..b00d57e2f0b 100644 --- a/Zend/zend_multibyte.h +++ b/Zend/zend_multibyte.h @@ -66,12 +66,12 @@ ZEND_API const char *zend_multibyte_get_encoding_name(const zend_encoding *encod ZEND_API int zend_multibyte_check_lexer_compatibility(const zend_encoding *encoding); ZEND_API const zend_encoding *zend_multibyte_encoding_detector(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size); 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); -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); +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); ZEND_API const zend_encoding *zend_multibyte_get_internal_encoding(void); ZEND_API const zend_encoding *zend_multibyte_get_script_encoding(void); ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size); -ZEND_API int zend_multibyte_set_internal_encoding(const zend_encoding *encoding); +ZEND_API zend_result zend_multibyte_set_internal_encoding(const zend_encoding *encoding); ZEND_API zend_result zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length); END_EXTERN_C() diff --git a/Zend/zend_signal.c b/Zend/zend_signal.c index 1cad564002a..f6ca3f40a3e 100644 --- a/Zend/zend_signal.c +++ b/Zend/zend_signal.c @@ -62,7 +62,7 @@ ZEND_API zend_signal_globals_t zend_signal_globals; #endif static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context); -static int zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*)); +static zend_result zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*)); #if defined(__CYGWIN__) || defined(__PASE__) /* Matches zend_execute_API.c; these platforms don't support ITIMER_PROF. */ diff --git a/Zend/zend_virtual_cwd.h b/Zend/zend_virtual_cwd.h index 728e3ba69d8..f819389af33 100644 --- a/Zend/zend_virtual_cwd.h +++ b/Zend/zend_virtual_cwd.h @@ -160,7 +160,7 @@ CWD_API int virtual_cwd_activate(void); CWD_API int virtual_cwd_deactivate(void); CWD_API char *virtual_getcwd_ex(size_t *length); CWD_API char *virtual_getcwd(char *buf, size_t size); -CWD_API int virtual_chdir(const char *path); +CWD_API zend_result virtual_chdir(const char *path); CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path)); CWD_API int virtual_filepath(const char *path, char **filepath); 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); #define VCWD_OPEN_MODE(path, flags, mode) virtual_open(path, flags, mode) #define VCWD_CREAT(path, mode) virtual_creat(path, mode) #define VCWD_CHDIR(path) virtual_chdir(path) -#define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, virtual_chdir) +#define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, (int (*)(const char *)) virtual_chdir) #define VCWD_GETWD(buf) #define VCWD_REALPATH(path, real_path) virtual_realpath(path, real_path) #define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname) diff --git a/ext/session/session.c b/ext/session/session.c index a2945b7a31c..c3ee25313fb 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -56,8 +56,8 @@ PHPAPI ZEND_DECLARE_MODULE_GLOBALS(ps) -static int php_session_rfc1867_callback(unsigned int event, void *event_data, void **extra); -static int (*php_session_rfc1867_orig_callback)(unsigned int event, void *event_data, void **extra); +static zend_result php_session_rfc1867_callback(unsigned int event, void *event_data, void **extra); +static zend_result (*php_session_rfc1867_orig_callback)(unsigned int event, void *event_data, void **extra); static void php_session_track_init(void); /* SessionHandler class */ @@ -97,8 +97,8 @@ zend_class_entry *php_session_update_timestamp_iface_entry; #define APPLY_TRANS_SID (PS(use_trans_sid) && !PS(use_only_cookies)) -static int php_session_send_cookie(void); -static int php_session_abort(void); +static zend_result php_session_send_cookie(void); +static zend_result php_session_abort(void); /* Initialized in MINIT, readonly otherwise. */ static int my_module_number = 0; diff --git a/main/rfc1867.c b/main/rfc1867.c index 4b1dcff3e23..f16af170b6a 100644 --- a/main/rfc1867.c +++ b/main/rfc1867.c @@ -49,7 +49,7 @@ static php_rfc1867_getword_t php_rfc1867_getword = php_ap_getword; static php_rfc1867_getword_conf_t php_rfc1867_getword_conf = php_ap_getword_conf; static php_rfc1867_basename_t php_rfc1867_basename = NULL; -PHPAPI int (*php_rfc1867_callback)(unsigned int event, void *event_data, void **extra) = NULL; +PHPAPI zend_result (*php_rfc1867_callback)(unsigned int event, void *event_data, void **extra) = NULL; static void safe_php_register_variable(char *var, char *strval, size_t val_len, zval *track_vars_array, bool override_protection); diff --git a/main/rfc1867.h b/main/rfc1867.h index e1ec2af87c4..bb690f15aa3 100644 --- a/main/rfc1867.h +++ b/main/rfc1867.h @@ -83,7 +83,7 @@ typedef char* (*php_rfc1867_basename_t)(const zend_encoding *encoding, char *str SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler); PHPAPI void destroy_uploaded_files_hash(void); -extern PHPAPI int (*php_rfc1867_callback)(unsigned int event, void *event_data, void **extra); +extern PHPAPI zend_result (*php_rfc1867_callback)(unsigned int event, void *event_data, void **extra); SAPI_API void php_rfc1867_set_multibyte_callbacks( php_rfc1867_encoding_translation_t encoding_translation,