Skip to content

Commit 2447cb2

Browse files
authored
main/output.c: Refine int return type to bool or zend_result (#13997)
1 parent de490c5 commit 2447cb2

File tree

5 files changed

+71
-71
lines changed

5 files changed

+71
-71
lines changed

ext/iconv/iconv.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
155155
static php_iconv_err_t php_iconv_stream_filter_register_factory(void);
156156
static php_iconv_err_t php_iconv_stream_filter_unregister_factory(void);
157157

158-
static int php_iconv_output_conflict(const char *handler_name, size_t handler_name_len);
158+
static zend_result php_iconv_output_conflict(const char *handler_name, size_t handler_name_len);
159159
static php_output_handler *php_iconv_output_handler_init(const char *name, size_t name_len, size_t chunk_size, int flags);
160-
static int php_iconv_output_handler(void **nothing, php_output_context *output_context);
160+
static zend_result php_iconv_output_handler(void **nothing, php_output_context *output_context);
161161
/* }}} */
162162

163163
/* {{{ static globals */
@@ -281,7 +281,7 @@ static const char *get_output_encoding(void) {
281281
}
282282

283283

284-
static int php_iconv_output_conflict(const char *handler_name, size_t handler_name_len)
284+
static zend_result php_iconv_output_conflict(const char *handler_name, size_t handler_name_len)
285285
{
286286
if (php_output_get_level()) {
287287
if (php_output_handler_conflict(handler_name, handler_name_len, ZEND_STRL("ob_iconv_handler"))
@@ -297,7 +297,7 @@ static php_output_handler *php_iconv_output_handler_init(const char *handler_nam
297297
return php_output_handler_create_internal(handler_name, handler_name_len, php_iconv_output_handler, chunk_size, flags);
298298
}
299299

300-
static int php_iconv_output_handler(void **nothing, php_output_context *output_context)
300+
static zend_result php_iconv_output_handler(void **nothing, php_output_context *output_context)
301301
{
302302
char *s, *content_type, *mimetype = NULL;
303303
int output_status, mimetype_len = 0;

ext/tidy/tidy.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static int _php_tidy_apply_config_array(TidyDoc doc, HashTable *ht_options);
147147
static PHP_INI_MH(php_tidy_set_clean_output);
148148
static void php_tidy_clean_output_start(const char *name, size_t name_len);
149149
static php_output_handler *php_tidy_output_handler_init(const char *handler_name, size_t handler_name_len, size_t chunk_size, int flags);
150-
static int php_tidy_output_handler(void **nothing, php_output_context *output_context);
150+
static zend_result php_tidy_output_handler(void **nothing, php_output_context *output_context);
151151

152152
static PHP_MINIT_FUNCTION(tidy);
153153
static PHP_MSHUTDOWN_FUNCTION(tidy);
@@ -953,9 +953,9 @@ static php_output_handler *php_tidy_output_handler_init(const char *handler_name
953953
return php_output_handler_create_internal(handler_name, handler_name_len, php_tidy_output_handler, chunk_size, flags);
954954
}
955955

956-
static int php_tidy_output_handler(void **nothing, php_output_context *output_context)
956+
static zend_result php_tidy_output_handler(void **nothing, php_output_context *output_context)
957957
{
958-
int status = FAILURE;
958+
zend_result status = FAILURE;
959959
TidyDoc doc;
960960
TidyBuffer inbuf, outbuf, errbuf;
961961

ext/zlib/zlib.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static void php_zlib_free(voidpf opaque, voidpf address)
131131
/* }}} */
132132

133133
/* {{{ php_zlib_output_conflict_check() */
134-
static int php_zlib_output_conflict_check(const char *handler_name, size_t handler_name_len)
134+
static zend_result php_zlib_output_conflict_check(const char *handler_name, size_t handler_name_len)
135135
{
136136
if (php_output_get_level() > 0) {
137137
if (php_output_handler_conflict(handler_name, handler_name_len, ZEND_STRL(PHP_ZLIB_OUTPUT_HANDLER_NAME))
@@ -166,7 +166,7 @@ static int php_zlib_output_encoding(void)
166166
/* }}} */
167167

168168
/* {{{ php_zlib_output_handler_ex() */
169-
static int php_zlib_output_handler_ex(php_zlib_context *ctx, php_output_context *output_context)
169+
static zend_result php_zlib_output_handler_ex(php_zlib_context *ctx, php_output_context *output_context)
170170
{
171171
int flags = Z_SYNC_FLUSH;
172172

@@ -252,7 +252,7 @@ static int php_zlib_output_handler_ex(php_zlib_context *ctx, php_output_context
252252
/* }}} */
253253

254254
/* {{{ php_zlib_output_handler() */
255-
static int php_zlib_output_handler(void **handler_context, php_output_context *output_context)
255+
static zend_result php_zlib_output_handler(void **handler_context, php_output_context *output_context)
256256
{
257257
php_zlib_context *ctx = *(php_zlib_context **) handler_context;
258258

@@ -526,7 +526,7 @@ PHP_FUNCTION(ob_gzhandler)
526526
size_t in_len;
527527
zend_long flags = 0;
528528
php_output_context ctx = {0};
529-
int encoding, rv;
529+
int encoding;
530530

531531
/*
532532
* NOTE that the real ob_gzhandler is an alias to "zlib output compression".
@@ -564,7 +564,7 @@ PHP_FUNCTION(ob_gzhandler)
564564
ctx.in.data = in_str;
565565
ctx.in.used = in_len;
566566

567-
rv = php_zlib_output_handler_ex(ZLIBG(ob_gzhandler), &ctx);
567+
zend_result rv = php_zlib_output_handler_ex(ZLIBG(ob_gzhandler), &ctx);
568568

569569
if (SUCCESS != rv) {
570570
if (ctx.out.data && ctx.out.free) {

main/output.c

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -48,29 +48,29 @@ static HashTable php_output_handler_reverse_conflicts;
4848
/* }}} */
4949

5050
/* {{{ forward declarations */
51-
static inline int php_output_lock_error(int op);
51+
static inline bool php_output_lock_error(int op);
5252
static inline void php_output_op(int op, const char *str, size_t len);
5353

5454
static inline php_output_handler *php_output_handler_init(zend_string *name, size_t chunk_size, int flags);
5555
static inline php_output_handler_status_t php_output_handler_op(php_output_handler *handler, php_output_context *context);
56-
static inline int php_output_handler_append(php_output_handler *handler, const php_output_buffer *buf);
56+
static inline bool php_output_handler_append(php_output_handler *handler, const php_output_buffer *buf);
5757
static inline zval *php_output_handler_status(php_output_handler *handler, zval *entry);
5858

5959
static inline void php_output_context_init(php_output_context *context, int op);
6060
static inline void php_output_context_reset(php_output_context *context);
6161
static inline void php_output_context_swap(php_output_context *context);
6262
static inline void php_output_context_dtor(php_output_context *context);
6363

64-
static int php_output_stack_pop(int flags);
64+
static zend_result php_output_stack_pop(int flags);
6565

6666
static int php_output_stack_apply_op(void *h, void *c);
6767
static int php_output_stack_apply_clean(void *h, void *c);
6868
static int php_output_stack_apply_list(void *h, void *z);
6969
static int php_output_stack_apply_status(void *h, void *z);
7070

71-
static int php_output_handler_compat_func(void **handler_context, php_output_context *output_context);
72-
static int php_output_handler_default_func(void **handler_context, php_output_context *output_context);
73-
static int php_output_handler_devnull_func(void **handler_context, php_output_context *output_context);
71+
static zend_result php_output_handler_compat_func(void **handler_context, php_output_context *output_context);
72+
static zend_result php_output_handler_default_func(void **handler_context, php_output_context *output_context);
73+
static zend_result php_output_handler_devnull_func(void **handler_context, php_output_context *output_context);
7474
/* }}} */
7575

7676
/* {{{ static void php_output_init_globals(zend_output_globals *G)
@@ -250,7 +250,7 @@ PHPAPI size_t php_output_write(const char *str, size_t len)
250250

251251
/* {{{ SUCCESS|FAILURE php_output_flush(void)
252252
* Flush the most recent output handlers buffer */
253-
PHPAPI int php_output_flush(void)
253+
PHPAPI zend_result php_output_flush(void)
254254
{
255255
php_output_context context;
256256

@@ -281,7 +281,7 @@ PHPAPI void php_output_flush_all(void)
281281

282282
/* {{{ SUCCESS|FAILURE php_output_clean(void)
283283
* Cleans the most recent output handlers buffer if the handler is cleanable */
284-
PHPAPI int php_output_clean(void)
284+
PHPAPI zend_result php_output_clean(void)
285285
{
286286
php_output_context context;
287287

@@ -309,7 +309,7 @@ PHPAPI void php_output_clean_all(void)
309309

310310
/* {{{ SUCCESS|FAILURE php_output_end(void)
311311
* Finalizes the most recent output handler at pops it off the stack if the handler is removable */
312-
PHPAPI int php_output_end(void)
312+
PHPAPI zend_result php_output_end(void)
313313
{
314314
if (php_output_stack_pop(PHP_OUTPUT_POP_TRY)) {
315315
return SUCCESS;
@@ -328,7 +328,7 @@ PHPAPI void php_output_end_all(void)
328328

329329
/* {{{ SUCCESS|FAILURE php_output_discard(void)
330330
* Discards the most recent output handlers buffer and pops it off the stack if the handler is removable */
331-
PHPAPI int php_output_discard(void)
331+
PHPAPI zend_result php_output_discard(void)
332332
{
333333
if (php_output_stack_pop(PHP_OUTPUT_POP_DISCARD|PHP_OUTPUT_POP_TRY)) {
334334
return SUCCESS;
@@ -357,7 +357,7 @@ PHPAPI int php_output_get_level(void)
357357

358358
/* {{{ SUCCESS|FAILURE php_output_get_contents(zval *z)
359359
* Get the contents of the active output handlers buffer */
360-
PHPAPI int php_output_get_contents(zval *p)
360+
PHPAPI zend_result php_output_get_contents(zval *p)
361361
{
362362
if (OG(active)) {
363363
ZVAL_STRINGL(p, OG(active)->buffer.data, OG(active)->buffer.used);
@@ -370,7 +370,7 @@ PHPAPI int php_output_get_contents(zval *p)
370370

371371
/* {{{ SUCCESS|FAILURE php_output_get_length(zval *z)
372372
* Get the length of the active output handlers buffer */
373-
PHPAPI int php_output_get_length(zval *p)
373+
PHPAPI zend_result php_output_get_length(zval *p)
374374
{
375375
if (OG(active)) {
376376
ZVAL_LONG(p, OG(active)->buffer.used);
@@ -392,7 +392,7 @@ PHPAPI php_output_handler* php_output_get_active_handler(void)
392392

393393
/* {{{ SUCCESS|FAILURE php_output_handler_start_default(void)
394394
* Start a "default output handler" */
395-
PHPAPI int php_output_start_default(void)
395+
PHPAPI zend_result php_output_start_default(void)
396396
{
397397
php_output_handler *handler;
398398

@@ -407,7 +407,7 @@ PHPAPI int php_output_start_default(void)
407407

408408
/* {{{ SUCCESS|FAILURE php_output_handler_start_devnull(void)
409409
* Start a "null output handler" */
410-
PHPAPI int php_output_start_devnull(void)
410+
PHPAPI zend_result php_output_start_devnull(void)
411411
{
412412
php_output_handler *handler;
413413

@@ -422,7 +422,7 @@ PHPAPI int php_output_start_devnull(void)
422422

423423
/* {{{ SUCCESS|FAILURE php_output_start_user(zval *handler, size_t chunk_size, int flags)
424424
* Start a user level output handler */
425-
PHPAPI int php_output_start_user(zval *output_handler, size_t chunk_size, int flags)
425+
PHPAPI zend_result php_output_start_user(zval *output_handler, size_t chunk_size, int flags)
426426
{
427427
php_output_handler *handler;
428428

@@ -441,7 +441,7 @@ PHPAPI int php_output_start_user(zval *output_handler, size_t chunk_size, int fl
441441

442442
/* {{{ SUCCESS|FAILURE php_output_start_internal(zval *name, php_output_handler_func_t handler, size_t chunk_size, int flags)
443443
* Start an internal output handler that does not have to maintain a non-global state */
444-
PHPAPI int php_output_start_internal(const char *name, size_t name_len, php_output_handler_func_t output_handler, size_t chunk_size, int flags)
444+
PHPAPI zend_result php_output_start_internal(const char *name, size_t name_len, php_output_handler_func_t output_handler, size_t chunk_size, int flags)
445445
{
446446
php_output_handler *handler;
447447

@@ -526,7 +526,7 @@ PHPAPI void php_output_handler_set_context(php_output_handler *handler, void *op
526526

527527
/* {{{ SUCCESS|FAILURE php_output_handler_start(php_output_handler *handler)
528528
* Starts the set up output handler and pushes it on top of the stack. Checks for any conflicts regarding the output handler to start */
529-
PHPAPI int php_output_handler_start(php_output_handler *handler)
529+
PHPAPI zend_result php_output_handler_start(php_output_handler *handler)
530530
{
531531
HashTable *rconflicts;
532532
php_output_handler_conflict_check_t conflict;
@@ -553,9 +553,9 @@ PHPAPI int php_output_handler_start(php_output_handler *handler)
553553
}
554554
/* }}} */
555555

556-
/* {{{ int php_output_handler_started(zval *name)
556+
/* {{{ bool php_output_handler_started(zval *name)
557557
* Check whether a certain output handler is in use */
558-
PHPAPI int php_output_handler_started(const char *name, size_t name_len)
558+
PHPAPI bool php_output_handler_started(const char *name, size_t name_len)
559559
{
560560
php_output_handler **handlers;
561561
int i, count = php_output_get_level();
@@ -565,34 +565,34 @@ PHPAPI int php_output_handler_started(const char *name, size_t name_len)
565565

566566
for (i = 0; i < count; ++i) {
567567
if (zend_string_equals_cstr(handlers[i]->name, name, name_len)) {
568-
return 1;
568+
return true;
569569
}
570570
}
571571
}
572572

573-
return 0;
573+
return false;
574574
}
575575
/* }}} */
576576

577-
/* {{{ int php_output_handler_conflict(zval *handler_new, zval *handler_old)
577+
/* {{{ bool php_output_handler_conflict(zval *handler_new, zval *handler_old)
578578
* Check whether a certain handler is in use and issue a warning that the new handler would conflict with the already used one */
579-
PHPAPI int php_output_handler_conflict(const char *handler_new, size_t handler_new_len, const char *handler_set, size_t handler_set_len)
579+
PHPAPI bool php_output_handler_conflict(const char *handler_new, size_t handler_new_len, const char *handler_set, size_t handler_set_len)
580580
{
581581
if (php_output_handler_started(handler_set, handler_set_len)) {
582582
if (handler_new_len != handler_set_len || memcmp(handler_new, handler_set, handler_set_len)) {
583583
php_error_docref("ref.outcontrol", E_WARNING, "Output handler '%s' conflicts with '%s'", handler_new, handler_set);
584584
} else {
585585
php_error_docref("ref.outcontrol", E_WARNING, "Output handler '%s' cannot be used twice", handler_new);
586586
}
587-
return 1;
587+
return true;
588588
}
589-
return 0;
589+
return false;
590590
}
591591
/* }}} */
592592

593593
/* {{{ SUCCESS|FAILURE php_output_handler_conflict_register(zval *name, php_output_handler_conflict_check_t check_func)
594594
* Register a conflict checking function on MINIT */
595-
PHPAPI int php_output_handler_conflict_register(const char *name, size_t name_len, php_output_handler_conflict_check_t check_func)
595+
PHPAPI zend_result php_output_handler_conflict_register(const char *name, size_t name_len, php_output_handler_conflict_check_t check_func)
596596
{
597597
zend_string *str;
598598

@@ -609,7 +609,7 @@ PHPAPI int php_output_handler_conflict_register(const char *name, size_t name_le
609609

610610
/* {{{ SUCCESS|FAILURE php_output_handler_reverse_conflict_register(zval *name, php_output_handler_conflict_check_t check_func)
611611
* Register a reverse conflict checking function on MINIT */
612-
PHPAPI int php_output_handler_reverse_conflict_register(const char *name, size_t name_len, php_output_handler_conflict_check_t check_func)
612+
PHPAPI zend_result php_output_handler_reverse_conflict_register(const char *name, size_t name_len, php_output_handler_conflict_check_t check_func)
613613
{
614614
HashTable rev, *rev_ptr = NULL;
615615

@@ -646,7 +646,7 @@ PHPAPI php_output_handler_alias_ctor_t php_output_handler_alias(const char *name
646646

647647
/* {{{ SUCCESS|FAILURE php_output_handler_alias_register(zval *name, php_output_handler_alias_ctor_t func)
648648
* Registers an internal output handler as alias for a user handler */
649-
PHPAPI int php_output_handler_alias_register(const char *name, size_t name_len, php_output_handler_alias_ctor_t func)
649+
PHPAPI zend_result php_output_handler_alias_register(const char *name, size_t name_len, php_output_handler_alias_ctor_t func)
650650
{
651651
zend_string *str;
652652

@@ -663,7 +663,7 @@ PHPAPI int php_output_handler_alias_register(const char *name, size_t name_len,
663663

664664
/* {{{ SUCCESS|FAILURE php_output_handler_hook(php_output_handler_hook_t type, void *arg)
665665
* Output handler hook for output handler functions to check/modify the current handlers abilities */
666-
PHPAPI int php_output_handler_hook(php_output_handler_hook_t type, void *arg)
666+
PHPAPI zend_result php_output_handler_hook(php_output_handler_hook_t type, void *arg)
667667
{
668668
if (OG(running)) {
669669
switch (type) {
@@ -751,18 +751,18 @@ PHPAPI int php_output_get_start_lineno(void)
751751
}
752752
/* }}} */
753753

754-
/* {{{ static int php_output_lock_error(int op)
754+
/* {{{ static bool php_output_lock_error(int op)
755755
* Checks whether an unallowed operation is attempted from within the output handler and issues a fatal error */
756-
static inline int php_output_lock_error(int op)
756+
static inline bool php_output_lock_error(int op)
757757
{
758758
/* if there's no ob active, ob has been stopped */
759759
if (op && OG(active) && OG(running)) {
760760
/* fatal error */
761761
php_output_deactivate();
762762
php_error_docref("ref.outcontrol", E_ERROR, "Cannot use output buffering in output buffering display handlers");
763-
return 1;
763+
return true;
764764
}
765-
return 0;
765+
return false;
766766
}
767767
/* }}} */
768768

@@ -865,9 +865,9 @@ static inline php_output_handler *php_output_handler_init(zend_string *name, siz
865865
}
866866
/* }}} */
867867

868-
/* {{{ static int php_output_handler_append(php_output_handler *handler, const php_output_buffer *buf)
868+
/* {{{ static bool php_output_handler_append(php_output_handler *handler, const php_output_buffer *buf)
869869
* Appends input to the output handlers buffer and indicates whether the buffer does not have to be processed by the output handler */
870-
static inline int php_output_handler_append(php_output_handler *handler, const php_output_buffer *buf)
870+
static inline bool php_output_handler_append(php_output_handler *handler, const php_output_buffer *buf)
871871
{
872872
if (buf->used) {
873873
OG(flags) |= PHP_OUTPUT_WRITTEN;
@@ -886,10 +886,10 @@ static inline int php_output_handler_append(php_output_handler *handler, const p
886886
/* chunked buffering */
887887
if (handler->size && (handler->buffer.used >= handler->size)) {
888888
/* store away errors and/or any intermediate output */
889-
return OG(running) ? 1 : 0;
889+
return OG(running) ? true : false;
890890
}
891891
}
892-
return 1;
892+
return true;
893893
}
894894
/* }}} */
895895

@@ -1243,7 +1243,7 @@ static int php_output_stack_pop(int flags)
12431243

12441244
/* {{{ static SUCCESS|FAILURE php_output_handler_compat_func(void *ctx, php_output_context *)
12451245
* php_output_handler_context_func_t for php_output_handler_func_t output handlers */
1246-
static int php_output_handler_compat_func(void **handler_context, php_output_context *output_context)
1246+
static zend_result php_output_handler_compat_func(void **handler_context, php_output_context *output_context)
12471247
{
12481248
php_output_handler_func_t func = *(php_output_handler_func_t *) handler_context;
12491249

@@ -1269,7 +1269,7 @@ static int php_output_handler_compat_func(void **handler_context, php_output_con
12691269

12701270
/* {{{ static SUCCESS|FAILURE php_output_handler_default_func(void *ctx, php_output_context *)
12711271
* Default output handler */
1272-
static int php_output_handler_default_func(void **handler_context, php_output_context *output_context)
1272+
static zend_result php_output_handler_default_func(void **handler_context, php_output_context *output_context)
12731273
{
12741274
php_output_context_pass(output_context);
12751275
return SUCCESS;
@@ -1278,7 +1278,7 @@ static int php_output_handler_default_func(void **handler_context, php_output_co
12781278

12791279
/* {{{ static SUCCESS|FAILURE php_output_handler_devnull_func(void *ctx, php_output_context *)
12801280
* Null output handler */
1281-
static int php_output_handler_devnull_func(void **handler_context, php_output_context *output_context)
1281+
static zend_result php_output_handler_devnull_func(void **handler_context, php_output_context *output_context)
12821282
{
12831283
return SUCCESS;
12841284
}

0 commit comments

Comments
 (0)