From 9726721560a3abe611ac534f00f9609ca67102ea Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Wed, 10 Jan 2024 22:19:23 +0000 Subject: [PATCH] general signatures discrepencies fixes (#13122) --- UPGRADING.INTERNALS | 4 ++++ Zend/zend_generators.c | 2 +- Zend/zend_interfaces.c | 3 +-- Zend/zend_iterators.h | 2 +- Zend/zend_multibyte.c | 2 +- Zend/zend_weakrefs.c | 2 +- ext/com_dotnet/com_iterator.c | 2 +- ext/com_dotnet/com_saproxy.c | 2 +- ext/date/php_date.c | 2 +- ext/dom/dom_iterators.c | 2 +- ext/ffi/ffi.c | 2 +- ext/gd/gd.c | 2 +- ext/intl/common/common_enum.cpp | 2 +- ext/intl/common/common_enum.h | 2 +- ext/intl/resourcebundle/resourcebundle_iterator.c | 2 +- ext/mysqli/mysqli_result_iterator.c | 2 +- ext/pdo/pdo_stmt.c | 2 +- ext/simplexml/simplexml.c | 4 ++-- ext/spl/spl_array.c | 2 +- ext/spl/spl_directory.c | 4 ++-- ext/spl/spl_dllist.c | 2 +- ext/spl/spl_fixedarray.c | 2 +- ext/spl/spl_heap.c | 2 +- ext/spl/spl_iterators.c | 8 ++++---- ext/zend_test/iterators.c | 2 +- 25 files changed, 33 insertions(+), 30 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 8dd5a62f50e..c768ab1366d 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -26,6 +26,10 @@ PHP 8.4 INTERNALS UPGRADE NOTES Z_PARAM_FUNC_EX2 was added as well with the same arguments as Z_PARAM_FUNC_EX plus an additional argument free_trampoline. +* The zend_object_iterator_funcs valid member has changed its signature from + int(*)(zend_object_iterator *) to zend_result(*)(zend_object_iterator *) to + be more in line with what callbacks are returning. + ======================== 2. Build system changes ======================== diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 0ab0257f877..036aba09805 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -1018,7 +1018,7 @@ static void zend_generator_iterator_dtor(zend_object_iterator *iterator) /* {{{ } /* }}} */ -static int zend_generator_iterator_valid(zend_object_iterator *iterator) /* {{{ */ +static zend_result zend_generator_iterator_valid(zend_object_iterator *iterator) /* {{{ */ { zend_generator *generator = (zend_generator*)Z_OBJ(iterator->data); diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index 5148668d945..49b0df3bb7d 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -198,8 +198,7 @@ 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, - // FIXME: Adjust the actual function prototype in zend_object_iterator_funcs - (int (*)(zend_object_iterator *)) zend_user_it_valid, + 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_iterators.h b/Zend/zend_iterators.h index 5e7451f7eac..7d237982034 100644 --- a/Zend/zend_iterators.h +++ b/Zend/zend_iterators.h @@ -31,7 +31,7 @@ typedef struct _zend_object_iterator_funcs { void (*dtor)(zend_object_iterator *iter); /* check for end of iteration (FAILURE or SUCCESS if data is valid) */ - int (*valid)(zend_object_iterator *iter); + zend_result (*valid)(zend_object_iterator *iter); /* fetch the item data for the current element */ zval *(*get_current_data)(zend_object_iterator *iter); diff --git a/Zend/zend_multibyte.c b/Zend/zend_multibyte.c index f8dab668751..9459920b633 100644 --- a/Zend/zend_multibyte.c +++ b/Zend/zend_multibyte.c @@ -170,7 +170,7 @@ ZEND_API const zend_encoding *zend_multibyte_get_script_encoding(void) return LANG_SCNG(script_encoding); } -ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size) +ZEND_API zend_result zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size) { if (CG(script_encoding_list)) { free((char*)CG(script_encoding_list)); diff --git a/Zend/zend_weakrefs.c b/Zend/zend_weakrefs.c index 442b19fb62a..7a9bf14cb15 100644 --- a/Zend/zend_weakrefs.c +++ b/Zend/zend_weakrefs.c @@ -597,7 +597,7 @@ static void zend_weakmap_iterator_dtor(zend_object_iterator *obj_iter) zval_ptr_dtor(&iter->it.data); } -static int zend_weakmap_iterator_valid(zend_object_iterator *obj_iter) +static zend_result zend_weakmap_iterator_valid(zend_object_iterator *obj_iter) { zend_weakmap_iterator *iter = (zend_weakmap_iterator *) obj_iter; zend_weakmap *wm = zend_weakmap_fetch(&iter->it.data); diff --git a/ext/com_dotnet/com_iterator.c b/ext/com_dotnet/com_iterator.c index 0bf4789b0ce..9aaf5e96ab4 100644 --- a/ext/com_dotnet/com_iterator.c +++ b/ext/com_dotnet/com_iterator.c @@ -49,7 +49,7 @@ static void com_iter_dtor(zend_object_iterator *iter) zval_ptr_dtor(&I->zdata); } -static int com_iter_valid(zend_object_iterator *iter) +static zend_result com_iter_valid(zend_object_iterator *iter) { struct php_com_iterator *I = (struct php_com_iterator*)Z_PTR(iter->data); diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c index c99a622070e..83c37964a9f 100644 --- a/ext/com_dotnet/com_saproxy.c +++ b/ext/com_dotnet/com_saproxy.c @@ -455,7 +455,7 @@ static void saproxy_iter_dtor(zend_object_iterator *iter) efree(I); } -static int saproxy_iter_valid(zend_object_iterator *iter) +static zend_result saproxy_iter_valid(zend_object_iterator *iter) { php_com_saproxy_iter *I = (php_com_saproxy_iter*)Z_PTR(iter->data); diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 02236d6676e..3829a6cfdb7 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -1575,7 +1575,7 @@ static void date_period_it_dtor(zend_object_iterator *iter) /* }}} */ /* {{{ date_period_it_has_more */ -static int date_period_it_has_more(zend_object_iterator *iter) +static zend_result date_period_it_has_more(zend_object_iterator *iter) { date_period_it *iterator = (date_period_it *)iter; php_period_obj *object = Z_PHPPERIOD_P(&iterator->intern.data); diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c index 21d59c5f02b..bb151c19895 100644 --- a/ext/dom/dom_iterators.c +++ b/ext/dom/dom_iterators.c @@ -132,7 +132,7 @@ static void php_dom_iterator_dtor(zend_object_iterator *iter) /* {{{ */ } /* }}} */ -static int php_dom_iterator_valid(zend_object_iterator *iter) /* {{{ */ +static zend_result php_dom_iterator_valid(zend_object_iterator *iter) /* {{{ */ { php_dom_iterator *iterator = (php_dom_iterator *)iter; diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index 6ac40f7704e..d98b6ef1ea8 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -1933,7 +1933,7 @@ static void zend_ffi_cdata_it_dtor(zend_object_iterator *iter) /* {{{ */ } /* }}} */ -static int zend_ffi_cdata_it_valid(zend_object_iterator *it) /* {{{ */ +static zend_result zend_ffi_cdata_it_valid(zend_object_iterator *it) /* {{{ */ { zend_ffi_cdata_iterator *iter = (zend_ffi_cdata_iterator*)it; zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ(iter->it.data); diff --git a/ext/gd/gd.c b/ext/gd/gd.c index dade3dddae0..4a347fa13fb 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -4058,7 +4058,7 @@ static gdIOCtx *create_stream_context(php_stream *stream, int close_stream) { return ctx; } -static gdIOCtx *create_output_context() { +static gdIOCtx *create_output_context(void) { gdIOCtx *ctx = ecalloc(1, sizeof(gdIOCtx)); ctx->putC = _php_image_output_putc; diff --git a/ext/intl/common/common_enum.cpp b/ext/intl/common/common_enum.cpp index 874c748d58b..8c618314bed 100644 --- a/ext/intl/common/common_enum.cpp +++ b/ext/intl/common/common_enum.cpp @@ -56,7 +56,7 @@ void zoi_with_current_dtor(zend_object_iterator *iter) } } -U_CFUNC int zoi_with_current_valid(zend_object_iterator *iter) +U_CFUNC zend_result zoi_with_current_valid(zend_object_iterator *iter) { return Z_ISUNDEF(((zoi_with_current*)iter)->current)? FAILURE : SUCCESS; } diff --git a/ext/intl/common/common_enum.h b/ext/intl/common/common_enum.h index ebe5cbfbfa3..7c56f34715c 100644 --- a/ext/intl/common/common_enum.h +++ b/ext/intl/common/common_enum.h @@ -68,7 +68,7 @@ extern zend_class_entry *IntlIterator_ce_ptr; extern zend_object_handlers IntlIterator_handlers; U_CFUNC void zoi_with_current_dtor(zend_object_iterator *iter); -U_CFUNC int zoi_with_current_valid(zend_object_iterator *iter); +U_CFUNC zend_result zoi_with_current_valid(zend_object_iterator *iter); U_CFUNC zval *zoi_with_current_get_current_data(zend_object_iterator *iter); U_CFUNC void zoi_with_current_invalidate_current(zend_object_iterator *iter); diff --git a/ext/intl/resourcebundle/resourcebundle_iterator.c b/ext/intl/resourcebundle/resourcebundle_iterator.c index 9ec97f64f51..9cd82d29bbe 100644 --- a/ext/intl/resourcebundle/resourcebundle_iterator.c +++ b/ext/intl/resourcebundle/resourcebundle_iterator.c @@ -77,7 +77,7 @@ static void resourcebundle_iterator_dtor( zend_object_iterator *iter ) /* }}} */ /* {{{ resourcebundle_iterator_has_more */ -static int resourcebundle_iterator_has_more( zend_object_iterator *iter ) +static zend_result resourcebundle_iterator_has_more( zend_object_iterator *iter ) { ResourceBundle_iterator *iterator = (ResourceBundle_iterator *) iter; return (iterator->i < iterator->length) ? SUCCESS : FAILURE; diff --git a/ext/mysqli/mysqli_result_iterator.c b/ext/mysqli/mysqli_result_iterator.c index dff8d7c003c..c781fcae9de 100644 --- a/ext/mysqli/mysqli_result_iterator.c +++ b/ext/mysqli/mysqli_result_iterator.c @@ -74,7 +74,7 @@ static void php_mysqli_result_iterator_dtor(zend_object_iterator *iter) /* }}} */ /* {{{ */ -static int php_mysqli_result_iterator_valid(zend_object_iterator *iter) +static zend_result php_mysqli_result_iterator_valid(zend_object_iterator *iter) { php_mysqli_result_iterator *iterator = (php_mysqli_result_iterator*) iter; diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 2d0010eb747..bb2efb4684a 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2159,7 +2159,7 @@ static void pdo_stmt_iter_dtor(zend_object_iterator *iter) } } -static int pdo_stmt_iter_valid(zend_object_iterator *iter) +static zend_result pdo_stmt_iter_valid(zend_object_iterator *iter) { struct php_pdo_iterator *I = (struct php_pdo_iterator*)iter; diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 02620fde9e2..a4b0ce1a07d 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -47,7 +47,7 @@ static xmlNodePtr php_sxe_reset_iterator(php_sxe_object *sxe, int use_data); static xmlNodePtr php_sxe_reset_iterator_no_clear_iter_data(php_sxe_object *sxe, int use_data); static xmlNodePtr php_sxe_iterator_fetch(php_sxe_object *sxe, xmlNodePtr node, int use_data); static void php_sxe_iterator_dtor(zend_object_iterator *iter); -static int php_sxe_iterator_valid(zend_object_iterator *iter); +static zend_result php_sxe_iterator_valid(zend_object_iterator *iter); static zval *php_sxe_iterator_current_data(zend_object_iterator *iter); static void php_sxe_iterator_current_key(zend_object_iterator *iter, zval *key); static void php_sxe_iterator_move_forward(zend_object_iterator *iter); @@ -2462,7 +2462,7 @@ static void php_sxe_iterator_dtor(zend_object_iterator *iter) /* {{{ */ } /* }}} */ -static int php_sxe_iterator_valid(zend_object_iterator *iter) /* {{{ */ +static zend_result php_sxe_iterator_valid(zend_object_iterator *iter) /* {{{ */ { php_sxe_iterator *iterator = (php_sxe_iterator *)iter; diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 4a9a5f59f5c..6a31a02da0b 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -1544,7 +1544,7 @@ static void spl_array_it_dtor(zend_object_iterator *iter) /* {{{ */ } /* }}} */ -static int spl_array_it_valid(zend_object_iterator *iter) /* {{{ */ +static zend_result spl_array_it_valid(zend_object_iterator *iter) /* {{{ */ { spl_array_object *object = Z_SPLARRAY_P(&iter->data); HashTable *aht = spl_array_get_hash_table(object); diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 528dc5ecc47..a8c54a24378 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -1627,7 +1627,7 @@ PHP_METHOD(GlobIterator, count) /* {{{ forward declarations to the iterator handlers */ static void spl_filesystem_dir_it_dtor(zend_object_iterator *iter); -static int spl_filesystem_dir_it_valid(zend_object_iterator *iter); +static zend_result spl_filesystem_dir_it_valid(zend_object_iterator *iter); static zval *spl_filesystem_dir_it_current_data(zend_object_iterator *iter); static void spl_filesystem_dir_it_current_key(zend_object_iterator *iter, zval *key); static void spl_filesystem_dir_it_move_forward(zend_object_iterator *iter); @@ -1677,7 +1677,7 @@ static void spl_filesystem_dir_it_dtor(zend_object_iterator *iter) /* }}} */ /* {{{ spl_filesystem_dir_it_valid */ -static int spl_filesystem_dir_it_valid(zend_object_iterator *iter) +static zend_result spl_filesystem_dir_it_valid(zend_object_iterator *iter) { spl_filesystem_object *object = spl_filesystem_iterator_to_object((spl_filesystem_iterator *)iter); diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index 74dc3b8c99f..d9c546f154a 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -875,7 +875,7 @@ static void spl_dllist_it_rewind(zend_object_iterator *iter) /* {{{ */ } /* }}} */ -static int spl_dllist_it_valid(zend_object_iterator *iter) /* {{{ */ +static zend_result spl_dllist_it_valid(zend_object_iterator *iter) /* {{{ */ { spl_dllist_it *iterator = (spl_dllist_it *)iter; spl_ptr_llist_element *element = iterator->traverse_pointer; diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index dbdc08c5a87..97116b470a4 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -895,7 +895,7 @@ static void spl_fixedarray_it_rewind(zend_object_iterator *iter) ((spl_fixedarray_it*)iter)->current = 0; } -static int spl_fixedarray_it_valid(zend_object_iterator *iter) +static zend_result spl_fixedarray_it_valid(zend_object_iterator *iter) { spl_fixedarray_it *iterator = (spl_fixedarray_it*)iter; spl_fixedarray_object *object = Z_SPLFIXEDARRAY_P(&iter->data); diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c index 5d617414251..83bca9e7238 100644 --- a/ext/spl/spl_heap.c +++ b/ext/spl/spl_heap.c @@ -896,7 +896,7 @@ static void spl_heap_it_rewind(zend_object_iterator *iter) /* {{{ */ } /* }}} */ -static int spl_heap_it_valid(zend_object_iterator *iter) /* {{{ */ +static zend_result spl_heap_it_valid(zend_object_iterator *iter) /* {{{ */ { return ((Z_SPLHEAP_P(&iter->data))->heap->count != 0 ? SUCCESS : FAILURE); } diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 482fb80acab..353eaecca24 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -210,7 +210,7 @@ static void spl_recursive_it_dtor(zend_object_iterator *_iter) zval_ptr_dtor(&iter->intern.data); } -static int spl_recursive_it_valid_ex(spl_recursive_it_object *object, zval *zthis) +static zend_result spl_recursive_it_valid_ex(spl_recursive_it_object *object, zval *zthis) { zend_object_iterator *sub_iter; int level = object->level; @@ -232,7 +232,7 @@ static int spl_recursive_it_valid_ex(spl_recursive_it_object *object, zval *zthi return FAILURE; } -static int spl_recursive_it_valid(zend_object_iterator *iter) +static zend_result spl_recursive_it_valid(zend_object_iterator *iter) { return spl_recursive_it_valid_ex(Z_SPLRECURSIVE_IT_P(&iter->data), &iter->data); } @@ -1525,7 +1525,7 @@ static inline void spl_dual_it_rewind(spl_dual_it_object *intern) } } -static inline int spl_dual_it_valid(spl_dual_it_object *intern) +static inline zend_result spl_dual_it_valid(spl_dual_it_object *intern) { if (!intern->inner.iterator) { return FAILURE; @@ -2184,7 +2184,7 @@ static zend_object *spl_dual_it_new(zend_class_entry *class_type) } /* }}} */ -static inline int spl_limit_it_valid(spl_dual_it_object *intern) +static inline zend_result spl_limit_it_valid(spl_dual_it_object *intern) { /* FAILURE / SUCCESS */ if (intern->u.limit.count != -1 && intern->current.pos >= intern->u.limit.offset + intern->u.limit.count) { diff --git a/ext/zend_test/iterators.c b/ext/zend_test/iterators.c index 53756ca79e1..47ea017d892 100644 --- a/ext/zend_test/iterators.c +++ b/ext/zend_test/iterators.c @@ -52,7 +52,7 @@ static void test_traversable_it_next(zend_object_iterator *iter) { ZVAL_LONG(&iterator->current, Z_LVAL(iterator->current) + 1); } -static int test_traversable_it_valid(zend_object_iterator *iter) { +static zend_result test_traversable_it_valid(zend_object_iterator *iter) { DUMP("TraversableTest::valid\n"); test_traversable_it *iterator = test_traversable_it_fetch(iter); if (Z_LVAL(iterator->current) < 4) {