diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index d6a9e265036..c697776dade 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -6388,7 +6388,7 @@ PHP_FUNCTION(pg_socket_poll) Z_PARAM_LONG(ts) ZEND_PARSE_PARAMETERS_END(); - if (php_stream_cast(stream, PHP_STREAM_AS_SOCKETD, (void **)&socket, 0)) { + if (UNEXPECTED(php_stream_cast(stream, PHP_STREAM_AS_SOCKETD, (void **)&socket, 0) == FAILURE)) { zend_argument_type_error(1, "invalid resource socket"); RETURN_THROWS(); } diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 3ed7d17bba2..3cae726838a 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -2585,7 +2585,7 @@ PHP_FUNCTION(socket_import_stream) ZEND_PARSE_PARAMETERS_END(); php_stream_from_zval(stream, zstream); - if (php_stream_cast(stream, PHP_STREAM_AS_SOCKETD, (void**)&socket, 1)) { + if (php_stream_cast(stream, PHP_STREAM_AS_SOCKETD, (void**)&socket, 1) == FAILURE) { /* error supposedly already shown */ RETURN_FALSE; } diff --git a/main/php_streams.h b/main/php_streams.h index 0391a2b7a64..d3a6660c6ca 100644 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -561,7 +561,7 @@ END_EXTERN_C() #define PHP_STREAM_CAST_INTERNAL 0x20000000 /* stream cast for internal use */ #define PHP_STREAM_CAST_MASK (PHP_STREAM_CAST_TRY_HARD | PHP_STREAM_CAST_RELEASE | PHP_STREAM_CAST_INTERNAL) BEGIN_EXTERN_C() -PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err); +PHPAPI zend_result _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err); END_EXTERN_C() /* use this to check if a stream can be cast into another form */ #define php_stream_can_cast(stream, as) _php_stream_cast((stream), (as), NULL, 0) @@ -626,7 +626,7 @@ END_EXTERN_C() /* this flag is only used by include/require functions */ #define STREAM_OPEN_FOR_ZEND_STREAM 0x00010000 -int php_init_stream_wrappers(int module_number); +zend_result php_init_stream_wrappers(int module_number); void php_shutdown_stream_wrappers(int module_number); void php_shutdown_stream_hashes(void); PHP_RSHUTDOWN_FUNCTION(streams); diff --git a/main/streams/cast.c b/main/streams/cast.c index 6e5c63fb3b2..5c78b560945 100644 --- a/main/streams/cast.c +++ b/main/streams/cast.c @@ -191,7 +191,7 @@ void php_stream_mode_sanitize_fdopen_fopencookie(php_stream *stream, char *resul /* }}} */ /* {{{ php_stream_cast */ -PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err) +PHPAPI zend_result _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err) { int flags = castas & PHP_STREAM_CAST_MASK; castas &= ~PHP_STREAM_CAST_MASK; @@ -273,12 +273,12 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show newstream = php_stream_fopen_tmpfile(); if (newstream) { - int retcopy = php_stream_copy_to_stream_ex(stream, newstream, PHP_STREAM_COPY_ALL, NULL); + zend_result retcopy = php_stream_copy_to_stream_ex(stream, newstream, PHP_STREAM_COPY_ALL, NULL); if (retcopy != SUCCESS) { php_stream_close(newstream); } else { - int retcast = php_stream_cast(newstream, castas | flags, (void **)ret, show_err); + zend_result retcast = php_stream_cast(newstream, castas | flags, (void **)ret, show_err); if (retcast == SUCCESS) { rewind(*(FILE**)ret); diff --git a/main/streams/filter.c b/main/streams/filter.c index 304eac0a155..2a48fae79f0 100644 --- a/main/streams/filter.c +++ b/main/streams/filter.c @@ -40,22 +40,22 @@ PHPAPI HashTable *_php_get_stream_filters_hash(void) } /* API for registering GLOBAL filters */ -PHPAPI int php_stream_filter_register_factory(const char *filterpattern, const php_stream_filter_factory *factory) +PHPAPI zend_result php_stream_filter_register_factory(const char *filterpattern, const php_stream_filter_factory *factory) { - int ret; + zend_result ret; zend_string *str = zend_string_init_interned(filterpattern, strlen(filterpattern), true); ret = zend_hash_add_ptr(&stream_filters_hash, str, (void*)factory) ? SUCCESS : FAILURE; zend_string_release_ex(str, true); return ret; } -PHPAPI int php_stream_filter_unregister_factory(const char *filterpattern) +PHPAPI zend_result php_stream_filter_unregister_factory(const char *filterpattern) { return zend_hash_str_del(&stream_filters_hash, filterpattern, strlen(filterpattern)); } /* API for registering VOLATILE wrappers */ -PHPAPI int php_stream_filter_register_factory_volatile(zend_string *filterpattern, const php_stream_filter_factory *factory) +PHPAPI zend_result php_stream_filter_register_factory_volatile(zend_string *filterpattern, const php_stream_filter_factory *factory) { if (!FG(stream_filters)) { ALLOC_HASHTABLE(FG(stream_filters)); @@ -282,7 +282,7 @@ PHPAPI void php_stream_filter_free(php_stream_filter *filter) pefree(filter, filter->is_persistent); } -PHPAPI int php_stream_filter_prepend_ex(php_stream_filter_chain *chain, php_stream_filter *filter) +PHPAPI zend_result php_stream_filter_prepend_ex(php_stream_filter_chain *chain, php_stream_filter *filter) { filter->next = chain->head; filter->prev = NULL; @@ -303,7 +303,7 @@ PHPAPI void _php_stream_filter_prepend(php_stream_filter_chain *chain, php_strea php_stream_filter_prepend_ex(chain, filter); } -PHPAPI int php_stream_filter_append_ex(php_stream_filter_chain *chain, php_stream_filter *filter) +PHPAPI zend_result php_stream_filter_append_ex(php_stream_filter_chain *chain, php_stream_filter *filter) { php_stream *stream = chain->stream; @@ -395,7 +395,7 @@ PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, php_stream } } -PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, bool finish) +PHPAPI zend_result _php_stream_filter_flush(php_stream_filter *filter, bool finish) { php_stream_bucket_brigade brig_a = { NULL, NULL }, brig_b = { NULL, NULL }, *inp = &brig_a, *outp = &brig_b, *brig_temp; php_stream_bucket *bucket; diff --git a/main/streams/php_stream_filter_api.h b/main/streams/php_stream_filter_api.h index 9d9ed24f861..8e697c2ad01 100644 --- a/main/streams/php_stream_filter_api.h +++ b/main/streams/php_stream_filter_api.h @@ -121,10 +121,10 @@ struct _php_stream_filter { /* stack filter onto a stream */ BEGIN_EXTERN_C() PHPAPI void _php_stream_filter_prepend(php_stream_filter_chain *chain, php_stream_filter *filter); -PHPAPI int php_stream_filter_prepend_ex(php_stream_filter_chain *chain, php_stream_filter *filter); +PHPAPI zend_result php_stream_filter_prepend_ex(php_stream_filter_chain *chain, php_stream_filter *filter); PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, php_stream_filter *filter); -PHPAPI int php_stream_filter_append_ex(php_stream_filter_chain *chain, php_stream_filter *filter); -PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, bool finish); +PHPAPI zend_result php_stream_filter_append_ex(php_stream_filter_chain *chain, php_stream_filter *filter); +PHPAPI zend_result _php_stream_filter_flush(php_stream_filter *filter, bool finish); PHPAPI php_stream_filter *php_stream_filter_remove(php_stream_filter *filter, bool call_dtor); PHPAPI void php_stream_filter_free(php_stream_filter *filter); PHPAPI php_stream_filter *_php_stream_filter_alloc(const php_stream_filter_ops *fops, void *abstract, uint8_t persistent STREAMS_DC); @@ -142,8 +142,8 @@ typedef struct _php_stream_filter_factory { } php_stream_filter_factory; BEGIN_EXTERN_C() -PHPAPI int php_stream_filter_register_factory(const char *filterpattern, const php_stream_filter_factory *factory); -PHPAPI int php_stream_filter_unregister_factory(const char *filterpattern); -PHPAPI int php_stream_filter_register_factory_volatile(zend_string *filterpattern, const php_stream_filter_factory *factory); +PHPAPI zend_result php_stream_filter_register_factory(const char *filterpattern, const php_stream_filter_factory *factory); +PHPAPI zend_result php_stream_filter_unregister_factory(const char *filterpattern); +PHPAPI zend_result php_stream_filter_register_factory_volatile(zend_string *filterpattern, const php_stream_filter_factory *factory); PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval *filterparams, uint8_t persistent); END_EXTERN_C() diff --git a/main/streams/streams.c b/main/streams/streams.c index 45bfaecf45e..fddca6f84a9 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -1869,7 +1869,7 @@ void php_shutdown_stream_hashes(void) } } -int php_init_stream_wrappers(int module_number) +zend_result php_init_stream_wrappers(int module_number) { le_stream = zend_register_list_destructors_ex(stream_resource_regular_dtor, NULL, "stream", module_number); le_pstream = zend_register_list_destructors_ex(NULL, stream_resource_persistent_dtor, "persistent stream", module_number); diff --git a/main/streams/userspace.c b/main/streams/userspace.c index 0bb80acf6b7..baf6c966057 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -297,7 +297,6 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char * php_userstream_data_t *us; zval zretval, zfuncname; zval args[4]; - int call_result; php_stream *stream = NULL; bool old_in_user_include; @@ -340,6 +339,7 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char * ZVAL_STRING(&zfuncname, USERSTREAM_OPEN); + zend_result call_result; zend_try { call_result = call_method_if_exists(&us->object, &zfuncname, &zretval, 4, args); } zend_catch { @@ -398,7 +398,6 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char php_userstream_data_t *us; zval zretval, zfuncname; zval args[2]; - int call_result; php_stream *stream = NULL; /* Try to catch bad usage without preventing flexibility */ @@ -426,7 +425,7 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char ZVAL_STRING(&zfuncname, USERSTREAM_DIR_OPEN); - call_result = call_method_if_exists(&us->object, &zfuncname, &zretval, 2, args); + zend_result call_result = call_method_if_exists(&us->object, &zfuncname, &zretval, 2, args); if (call_result == SUCCESS && Z_TYPE(zretval) != IS_UNDEF && zval_is_true(&zretval)) { /* the stream is now open! */ @@ -564,7 +563,6 @@ static ssize_t php_userstreamop_write(php_stream *stream, const char *buf, size_ { zval func_name; zval retval; - int call_result; php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract; zval args[1]; ssize_t didwrite; @@ -575,7 +573,7 @@ static ssize_t php_userstreamop_write(php_stream *stream, const char *buf, size_ ZVAL_STRINGL(&args[0], (char*)buf, count); - call_result = call_method_if_exists(&us->object, &func_name, &retval, 1, args); + zend_result call_result = call_method_if_exists(&us->object, &func_name, &retval, 1, args); zval_ptr_dtor(&args[0]); zval_ptr_dtor(&func_name); @@ -614,7 +612,6 @@ static ssize_t php_userstreamop_read(php_stream *stream, char *buf, size_t count zval func_name; zval retval; zval args[1]; - int call_result; size_t didread = 0; php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract; @@ -624,7 +621,7 @@ static ssize_t php_userstreamop_read(php_stream *stream, char *buf, size_t count ZVAL_LONG(&args[0], count); - call_result = call_method_if_exists(&us->object, &func_name, &retval, 1, args); + zend_result call_result = call_method_if_exists(&us->object, &func_name, &retval, 1, args); zval_ptr_dtor(&args[0]); zval_ptr_dtor(&func_name); @@ -714,14 +711,13 @@ static int php_userstreamop_flush(php_stream *stream) { zval func_name; zval retval; - int call_result; php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract; assert(us != NULL); ZVAL_STRINGL(&func_name, USERSTREAM_FLUSH, sizeof(USERSTREAM_FLUSH)-1); - call_result = call_method_if_exists(&us->object, &func_name, &retval, 0, NULL); + zend_result call_result = call_method_if_exists(&us->object, &func_name, &retval, 0, NULL); if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zval_is_true(&retval)) call_result = 0; @@ -738,7 +734,7 @@ static int php_userstreamop_seek(php_stream *stream, zend_off_t offset, int when { zval func_name; zval retval; - int call_result, ret; + int ret; php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract; zval args[2]; @@ -749,7 +745,7 @@ static int php_userstreamop_seek(php_stream *stream, zend_off_t offset, int when ZVAL_LONG(&args[0], offset); ZVAL_LONG(&args[1], whence); - call_result = call_method_if_exists(&us->object, &func_name, &retval, 2, args); + zend_result call_result = call_method_if_exists(&us->object, &func_name, &retval, 2, args); zval_ptr_dtor(&args[0]); zval_ptr_dtor(&args[1]); @@ -838,13 +834,12 @@ static int php_userstreamop_stat(php_stream *stream, php_stream_statbuf *ssb) { zval func_name; zval retval; - int call_result; php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract; int ret = -1; ZVAL_STRINGL(&func_name, USERSTREAM_STAT, sizeof(USERSTREAM_STAT)-1); - call_result = call_method_if_exists(&us->object, &func_name, &retval, 0, NULL); + zend_result call_result = call_method_if_exists(&us->object, &func_name, &retval, 0, NULL); if (call_result == SUCCESS && Z_TYPE(retval) == IS_ARRAY) { statbuf_from_array(&retval, ssb); @@ -866,7 +861,7 @@ static int php_userstreamop_stat(php_stream *stream, php_stream_statbuf *ssb) static int php_userstreamop_set_option(php_stream *stream, int option, int value, void *ptrparam) { zval func_name; zval retval; - int call_result; + zend_result call_result; php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract; int ret = PHP_STREAM_OPTION_RETURN_NOTIMPL; zval args[3]; @@ -1034,7 +1029,6 @@ static int user_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract; zval zfuncname, zretval; zval args[1]; - int call_result; zval object; int ret = 0; @@ -1049,7 +1043,7 @@ static int user_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int ZVAL_STRING(&zfuncname, USERSTREAM_UNLINK); - call_result = call_method_if_exists(&object, &zfuncname, &zretval, 1, args); + zend_result call_result = call_method_if_exists(&object, &zfuncname, &zretval, 1, args); if (call_result == SUCCESS && (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE)) { ret = (Z_TYPE(zretval) == IS_TRUE); @@ -1073,7 +1067,6 @@ static int user_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract; zval zfuncname, zretval; zval args[2]; - int call_result; zval object; int ret = 0; @@ -1089,7 +1082,7 @@ static int user_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from ZVAL_STRING(&zfuncname, USERSTREAM_RENAME); - call_result = call_method_if_exists(&object, &zfuncname, &zretval, 2, args); + zend_result call_result = call_method_if_exists(&object, &zfuncname, &zretval, 2, args); if (call_result == SUCCESS && (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE)) { ret = (Z_TYPE(zretval) == IS_TRUE); @@ -1114,7 +1107,6 @@ static int user_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url, int struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract; zval zfuncname, zretval; zval args[3]; - int call_result; zval object; int ret = 0; @@ -1131,7 +1123,7 @@ static int user_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url, int ZVAL_STRING(&zfuncname, USERSTREAM_MKDIR); - call_result = call_method_if_exists(&object, &zfuncname, &zretval, 3, args); + zend_result call_result = call_method_if_exists(&object, &zfuncname, &zretval, 3, args); if (call_result == SUCCESS && (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE)) { ret = (Z_TYPE(zretval) == IS_TRUE); @@ -1157,7 +1149,6 @@ static int user_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract; zval zfuncname, zretval; zval args[2]; - int call_result; zval object; int ret = 0; @@ -1173,7 +1164,7 @@ static int user_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, ZVAL_STRING(&zfuncname, USERSTREAM_RMDIR); - call_result = call_method_if_exists(&object, &zfuncname, &zretval, 2, args); + zend_result call_result = call_method_if_exists(&object, &zfuncname, &zretval, 2, args); if (call_result == SUCCESS && (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE)) { ret = (Z_TYPE(zretval) == IS_TRUE); @@ -1198,7 +1189,6 @@ static int user_wrapper_metadata(php_stream_wrapper *wrapper, const char *url, i struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract; zval zfuncname, zretval; zval args[3]; - int call_result; zval object; int ret = 0; @@ -1239,7 +1229,7 @@ static int user_wrapper_metadata(php_stream_wrapper *wrapper, const char *url, i ZVAL_STRING(&zfuncname, USERSTREAM_METADATA); - call_result = call_method_if_exists(&object, &zfuncname, &zretval, 3, args); + zend_result call_result = call_method_if_exists(&object, &zfuncname, &zretval, 3, args); if (call_result == SUCCESS && (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE)) { ret = Z_TYPE(zretval) == IS_TRUE; @@ -1266,7 +1256,6 @@ static int user_wrapper_stat_url(php_stream_wrapper *wrapper, const char *url, i struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract; zval zfuncname, zretval; zval args[2]; - int call_result; zval object; int ret = -1; @@ -1282,7 +1271,7 @@ static int user_wrapper_stat_url(php_stream_wrapper *wrapper, const char *url, i ZVAL_STRING(&zfuncname, USERSTREAM_STATURL); - call_result = call_method_if_exists(&object, &zfuncname, &zretval, 2, args); + zend_result call_result = call_method_if_exists(&object, &zfuncname, &zretval, 2, args); if (call_result == SUCCESS && Z_TYPE(zretval) == IS_ARRAY) { /* We got the info we needed */ @@ -1311,7 +1300,6 @@ static ssize_t php_userstreamop_readdir(php_stream *stream, char *buf, size_t co { zval func_name; zval retval; - int call_result; size_t didread = 0; php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract; php_stream_dirent *ent = (php_stream_dirent*)buf; @@ -1322,7 +1310,7 @@ static ssize_t php_userstreamop_readdir(php_stream *stream, char *buf, size_t co ZVAL_STRINGL(&func_name, USERSTREAM_DIR_READ, sizeof(USERSTREAM_DIR_READ)-1); - call_result = call_method_if_exists(&us->object, &func_name, &retval, 0, NULL); + zend_result call_result = call_method_if_exists(&us->object, &func_name, &retval, 0, NULL); if (call_result == SUCCESS && Z_TYPE(retval) != IS_FALSE && Z_TYPE(retval) != IS_TRUE) { convert_to_string(&retval); @@ -1387,7 +1375,6 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr) zval retval; zval args[1]; php_stream * intstream = NULL; - int call_result; int ret = FAILURE; /* If we are checking if the stream can cast, no return pointer is provided, so do not emit errors */ bool report_errors = retptr; @@ -1403,7 +1390,7 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr) break; } - call_result = call_method_if_exists(&us->object, &func_name, &retval, 1, args); + zend_result call_result = call_method_if_exists(&us->object, &func_name, &retval, 1, args); do { if (call_result == FAILURE) {