Skip to content

Commit 841afdc

Browse files
committed
streams: use type zend_result instead of type int
1 parent b3551cc commit 841afdc

File tree

8 files changed

+38
-51
lines changed

8 files changed

+38
-51
lines changed

ext/pgsql/pgsql.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6388,7 +6388,7 @@ PHP_FUNCTION(pg_socket_poll)
63886388
Z_PARAM_LONG(ts)
63896389
ZEND_PARSE_PARAMETERS_END();
63906390

6391-
if (php_stream_cast(stream, PHP_STREAM_AS_SOCKETD, (void **)&socket, 0)) {
6391+
if (UNEXPECTED(php_stream_cast(stream, PHP_STREAM_AS_SOCKETD, (void **)&socket, 0) == FAILURE)) {
63926392
zend_argument_type_error(1, "invalid resource socket");
63936393
RETURN_THROWS();
63946394
}

ext/sockets/sockets.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2585,7 +2585,7 @@ PHP_FUNCTION(socket_import_stream)
25852585
ZEND_PARSE_PARAMETERS_END();
25862586
php_stream_from_zval(stream, zstream);
25872587

2588-
if (php_stream_cast(stream, PHP_STREAM_AS_SOCKETD, (void**)&socket, 1)) {
2588+
if (php_stream_cast(stream, PHP_STREAM_AS_SOCKETD, (void**)&socket, 1) == FAILURE) {
25892589
/* error supposedly already shown */
25902590
RETURN_FALSE;
25912591
}

main/php_streams.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ END_EXTERN_C()
561561
#define PHP_STREAM_CAST_INTERNAL 0x20000000 /* stream cast for internal use */
562562
#define PHP_STREAM_CAST_MASK (PHP_STREAM_CAST_TRY_HARD | PHP_STREAM_CAST_RELEASE | PHP_STREAM_CAST_INTERNAL)
563563
BEGIN_EXTERN_C()
564-
PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err);
564+
PHPAPI zend_result _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err);
565565
END_EXTERN_C()
566566
/* use this to check if a stream can be cast into another form */
567567
#define php_stream_can_cast(stream, as) _php_stream_cast((stream), (as), NULL, 0)
@@ -626,7 +626,7 @@ END_EXTERN_C()
626626
/* this flag is only used by include/require functions */
627627
#define STREAM_OPEN_FOR_ZEND_STREAM 0x00010000
628628

629-
int php_init_stream_wrappers(int module_number);
629+
zend_result php_init_stream_wrappers(int module_number);
630630
void php_shutdown_stream_wrappers(int module_number);
631631
void php_shutdown_stream_hashes(void);
632632
PHP_RSHUTDOWN_FUNCTION(streams);

main/streams/cast.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ void php_stream_mode_sanitize_fdopen_fopencookie(php_stream *stream, char *resul
191191
/* }}} */
192192

193193
/* {{{ php_stream_cast */
194-
PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err)
194+
PHPAPI zend_result _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err)
195195
{
196196
int flags = castas & PHP_STREAM_CAST_MASK;
197197
castas &= ~PHP_STREAM_CAST_MASK;
@@ -273,12 +273,12 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
273273

274274
newstream = php_stream_fopen_tmpfile();
275275
if (newstream) {
276-
int retcopy = php_stream_copy_to_stream_ex(stream, newstream, PHP_STREAM_COPY_ALL, NULL);
276+
zend_result retcopy = php_stream_copy_to_stream_ex(stream, newstream, PHP_STREAM_COPY_ALL, NULL);
277277

278278
if (retcopy != SUCCESS) {
279279
php_stream_close(newstream);
280280
} else {
281-
int retcast = php_stream_cast(newstream, castas | flags, (void **)ret, show_err);
281+
zend_result retcast = php_stream_cast(newstream, castas | flags, (void **)ret, show_err);
282282

283283
if (retcast == SUCCESS) {
284284
rewind(*(FILE**)ret);

main/streams/filter.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,22 @@ PHPAPI HashTable *_php_get_stream_filters_hash(void)
4040
}
4141

4242
/* API for registering GLOBAL filters */
43-
PHPAPI int php_stream_filter_register_factory(const char *filterpattern, const php_stream_filter_factory *factory)
43+
PHPAPI zend_result php_stream_filter_register_factory(const char *filterpattern, const php_stream_filter_factory *factory)
4444
{
45-
int ret;
45+
zend_result ret;
4646
zend_string *str = zend_string_init_interned(filterpattern, strlen(filterpattern), true);
4747
ret = zend_hash_add_ptr(&stream_filters_hash, str, (void*)factory) ? SUCCESS : FAILURE;
4848
zend_string_release_ex(str, true);
4949
return ret;
5050
}
5151

52-
PHPAPI int php_stream_filter_unregister_factory(const char *filterpattern)
52+
PHPAPI zend_result php_stream_filter_unregister_factory(const char *filterpattern)
5353
{
5454
return zend_hash_str_del(&stream_filters_hash, filterpattern, strlen(filterpattern));
5555
}
5656

5757
/* API for registering VOLATILE wrappers */
58-
PHPAPI int php_stream_filter_register_factory_volatile(zend_string *filterpattern, const php_stream_filter_factory *factory)
58+
PHPAPI zend_result php_stream_filter_register_factory_volatile(zend_string *filterpattern, const php_stream_filter_factory *factory)
5959
{
6060
if (!FG(stream_filters)) {
6161
ALLOC_HASHTABLE(FG(stream_filters));
@@ -282,7 +282,7 @@ PHPAPI void php_stream_filter_free(php_stream_filter *filter)
282282
pefree(filter, filter->is_persistent);
283283
}
284284

285-
PHPAPI int php_stream_filter_prepend_ex(php_stream_filter_chain *chain, php_stream_filter *filter)
285+
PHPAPI zend_result php_stream_filter_prepend_ex(php_stream_filter_chain *chain, php_stream_filter *filter)
286286
{
287287
filter->next = chain->head;
288288
filter->prev = NULL;
@@ -303,7 +303,7 @@ PHPAPI void _php_stream_filter_prepend(php_stream_filter_chain *chain, php_strea
303303
php_stream_filter_prepend_ex(chain, filter);
304304
}
305305

306-
PHPAPI int php_stream_filter_append_ex(php_stream_filter_chain *chain, php_stream_filter *filter)
306+
PHPAPI zend_result php_stream_filter_append_ex(php_stream_filter_chain *chain, php_stream_filter *filter)
307307
{
308308
php_stream *stream = chain->stream;
309309

@@ -395,7 +395,7 @@ PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, php_stream
395395
}
396396
}
397397

398-
PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, bool finish)
398+
PHPAPI zend_result _php_stream_filter_flush(php_stream_filter *filter, bool finish)
399399
{
400400
php_stream_bucket_brigade brig_a = { NULL, NULL }, brig_b = { NULL, NULL }, *inp = &brig_a, *outp = &brig_b, *brig_temp;
401401
php_stream_bucket *bucket;

main/streams/php_stream_filter_api.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ struct _php_stream_filter {
121121
/* stack filter onto a stream */
122122
BEGIN_EXTERN_C()
123123
PHPAPI void _php_stream_filter_prepend(php_stream_filter_chain *chain, php_stream_filter *filter);
124-
PHPAPI int php_stream_filter_prepend_ex(php_stream_filter_chain *chain, php_stream_filter *filter);
124+
PHPAPI zend_result php_stream_filter_prepend_ex(php_stream_filter_chain *chain, php_stream_filter *filter);
125125
PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, php_stream_filter *filter);
126-
PHPAPI int php_stream_filter_append_ex(php_stream_filter_chain *chain, php_stream_filter *filter);
127-
PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, bool finish);
126+
PHPAPI zend_result php_stream_filter_append_ex(php_stream_filter_chain *chain, php_stream_filter *filter);
127+
PHPAPI zend_result _php_stream_filter_flush(php_stream_filter *filter, bool finish);
128128
PHPAPI php_stream_filter *php_stream_filter_remove(php_stream_filter *filter, bool call_dtor);
129129
PHPAPI void php_stream_filter_free(php_stream_filter *filter);
130130
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 {
142142
} php_stream_filter_factory;
143143

144144
BEGIN_EXTERN_C()
145-
PHPAPI int php_stream_filter_register_factory(const char *filterpattern, const php_stream_filter_factory *factory);
146-
PHPAPI int php_stream_filter_unregister_factory(const char *filterpattern);
147-
PHPAPI int php_stream_filter_register_factory_volatile(zend_string *filterpattern, const php_stream_filter_factory *factory);
145+
PHPAPI zend_result php_stream_filter_register_factory(const char *filterpattern, const php_stream_filter_factory *factory);
146+
PHPAPI zend_result php_stream_filter_unregister_factory(const char *filterpattern);
147+
PHPAPI zend_result php_stream_filter_register_factory_volatile(zend_string *filterpattern, const php_stream_filter_factory *factory);
148148
PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval *filterparams, uint8_t persistent);
149149
END_EXTERN_C()

main/streams/streams.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,7 @@ void php_shutdown_stream_hashes(void)
18691869
}
18701870
}
18711871

1872-
int php_init_stream_wrappers(int module_number)
1872+
zend_result php_init_stream_wrappers(int module_number)
18731873
{
18741874
le_stream = zend_register_list_destructors_ex(stream_resource_regular_dtor, NULL, "stream", module_number);
18751875
le_pstream = zend_register_list_destructors_ex(NULL, stream_resource_persistent_dtor, "persistent stream", module_number);

0 commit comments

Comments
 (0)