Fix -Wenum-int-mismatch warnings on gcc 13

Closes GH-11103
This commit is contained in:
Ilija Tovilo 2023-04-19 16:59:20 +02:00
parent 04fd04acab
commit 6f63d4b274
No known key found for this signature in database
GPG key ID: A4F5D403F118200A
14 changed files with 38 additions and 22 deletions

View file

@ -51,6 +51,21 @@ PHP 8.3 INTERNALS UPGRADE NOTES
variable value. This avoids side-effects through destructors between the variable value. This avoids side-effects through destructors between the
assignment of the variable and the assignment to the result zval in the VM 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. (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 2. Build system changes

View file

@ -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_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 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); ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, int write, int insert);

View file

@ -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_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 bool zend_make_callable(zval *callable, zend_string **callable_name);
ZEND_API const char *zend_get_module_version(const char *module_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); 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);

View file

@ -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_op_array *compile_filename(int type, zend_string *filename);
ZEND_API zend_ast *zend_compile_string_to_ast( ZEND_API zend_ast *zend_compile_string_to_ast(
zend_string *code, struct _zend_arena **ast_arena, zend_string *filename); 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 zend_result 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 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 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 destroy_op_array(zend_op_array *op_array);
ZEND_API void zend_destroy_static_vars(zend_op_array *op_array); ZEND_API void zend_destroy_static_vars(zend_op_array *op_array);

View file

@ -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 */ #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 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); 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( zval * ZEND_FASTCALL zend_handle_named_arg(
zend_execute_data **call_ptr, zend_string *arg_name, zend_execute_data **call_ptr, zend_string *arg_name,
uint32_t *arg_num_ptr, void **cache_slot); 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) \ #define CACHE_ADDR(num) \
((void**)((char*)EX(run_time_cache) + (num))) ((void**)((char*)EX(run_time_cache) + (num)))

View file

@ -234,8 +234,8 @@ END_EXTERN_C()
/* INI parsing engine */ /* INI parsing engine */
typedef void (*zend_ini_parser_cb_t)(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg); typedef void (*zend_ini_parser_cb_t)(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg);
BEGIN_EXTERN_C() 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 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 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_string(const char *str, bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg);
END_EXTERN_C() END_EXTERN_C()
/* INI entries */ /* INI entries */

View file

@ -118,7 +118,7 @@ static void zend_user_it_dtor(zend_object_iterator *_iter)
/* }}} */ /* }}} */
/* {{{ zend_user_it_valid */ /* {{{ 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) { if (_iter) {
zend_user_iterator *iter = (zend_user_iterator*)_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 = { static const zend_object_iterator_funcs zend_interface_iterator_funcs_iterator = {
zend_user_it_dtor, 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_data,
zend_user_it_get_current_key, zend_user_it_get_current_key,
zend_user_it_move_forward, zend_user_it_move_forward,

View file

@ -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 zval* ZEND_FASTCALL zend_list_insert(void *ptr, int type);
ZEND_API void ZEND_FASTCALL zend_list_free(zend_resource *res); 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 void ZEND_FASTCALL zend_list_close(zend_resource *res);
ZEND_API zend_resource *zend_register_resource(void *rsrc_pointer, int rsrc_type); ZEND_API zend_resource *zend_register_resource(void *rsrc_pointer, int rsrc_type);

View file

@ -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 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 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 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_internal_encoding(void);
ZEND_API const zend_encoding *zend_multibyte_get_script_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_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); ZEND_API zend_result zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length);
END_EXTERN_C() END_EXTERN_C()

View file

@ -62,7 +62,7 @@ ZEND_API zend_signal_globals_t zend_signal_globals;
#endif #endif
static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context); 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__) #if defined(__CYGWIN__) || defined(__PASE__)
/* Matches zend_execute_API.c; these platforms don't support ITIMER_PROF. */ /* Matches zend_execute_API.c; these platforms don't support ITIMER_PROF. */

View file

@ -160,7 +160,7 @@ CWD_API int virtual_cwd_activate(void);
CWD_API int virtual_cwd_deactivate(void); CWD_API int virtual_cwd_deactivate(void);
CWD_API char *virtual_getcwd_ex(size_t *length); CWD_API char *virtual_getcwd_ex(size_t *length);
CWD_API char *virtual_getcwd(char *buf, size_t size); 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_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(const char *path, char **filepath);
CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path); 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_OPEN_MODE(path, flags, mode) virtual_open(path, flags, mode)
#define VCWD_CREAT(path, mode) virtual_creat(path, mode) #define VCWD_CREAT(path, mode) virtual_creat(path, mode)
#define VCWD_CHDIR(path) virtual_chdir(path) #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_GETWD(buf)
#define VCWD_REALPATH(path, real_path) virtual_realpath(path, real_path) #define VCWD_REALPATH(path, real_path) virtual_realpath(path, real_path)
#define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname) #define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname)

View file

@ -56,8 +56,8 @@
PHPAPI ZEND_DECLARE_MODULE_GLOBALS(ps) PHPAPI ZEND_DECLARE_MODULE_GLOBALS(ps)
static int php_session_rfc1867_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 int (*php_session_rfc1867_orig_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); static void php_session_track_init(void);
/* SessionHandler class */ /* 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)) #define APPLY_TRANS_SID (PS(use_trans_sid) && !PS(use_only_cookies))
static int php_session_send_cookie(void); static zend_result php_session_send_cookie(void);
static int php_session_abort(void); static zend_result php_session_abort(void);
/* Initialized in MINIT, readonly otherwise. */ /* Initialized in MINIT, readonly otherwise. */
static int my_module_number = 0; static int my_module_number = 0;

View file

@ -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_getword_conf_t php_rfc1867_getword_conf = php_ap_getword_conf;
static php_rfc1867_basename_t php_rfc1867_basename = NULL; 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); static void safe_php_register_variable(char *var, char *strval, size_t val_len, zval *track_vars_array, bool override_protection);

View file

@ -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); SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler);
PHPAPI void destroy_uploaded_files_hash(void); 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( SAPI_API void php_rfc1867_set_multibyte_callbacks(
php_rfc1867_encoding_translation_t encoding_translation, php_rfc1867_encoding_translation_t encoding_translation,