Skip to content

Commit 371ae12

Browse files
MaxKellermanndevnexen
authored andcommitted
Zend/zend_fibers: change return value to zend_result
According to @nikic: > The current guideline for use of bool and zend_result in php-src is > that bool is an appropriate return value for "is" or "has" style > functions, which return a yes/no answer. zend_result is an > appropriate return value for functions that perform some operation > that may succeed or fail. Closes GH-10622.
1 parent 81e59c6 commit 371ae12

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

UPGRADING.INTERNALS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ PHP 8.3 INTERNALS UPGRADE NOTES
3434
the class table. zend_register_class_alias_ex() will not increase
3535
the refcount for class aliases and the cleanup function takes this
3636
into account.
37+
* The return types of the following functions have been changed from
38+
`bool` to `zend_result`:
39+
- zend_fiber_init_context()
3740

3841
========================
3942
2. Build system changes

Zend/zend_fibers.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,12 @@ ZEND_API bool zend_fiber_switch_blocked(void)
394394
return zend_fiber_switch_blocking;
395395
}
396396

397-
ZEND_API bool zend_fiber_init_context(zend_fiber_context *context, void *kind, zend_fiber_coroutine coroutine, size_t stack_size)
397+
ZEND_API zend_result zend_fiber_init_context(zend_fiber_context *context, void *kind, zend_fiber_coroutine coroutine, size_t stack_size)
398398
{
399399
context->stack = zend_fiber_stack_allocate(stack_size);
400400

401401
if (UNEXPECTED(!context->stack)) {
402-
return false;
402+
return FAILURE;
403403
}
404404

405405
#ifdef ZEND_FIBER_UCONTEXT
@@ -438,7 +438,7 @@ ZEND_API bool zend_fiber_init_context(zend_fiber_context *context, void *kind, z
438438

439439
zend_observer_fiber_init_notify(context);
440440

441-
return true;
441+
return SUCCESS;
442442
}
443443

444444
ZEND_API void zend_fiber_destroy_context(zend_fiber_context *context)
@@ -812,7 +812,7 @@ ZEND_METHOD(Fiber, start)
812812
RETURN_THROWS();
813813
}
814814

815-
if (!zend_fiber_init_context(&fiber->context, zend_ce_fiber, zend_fiber_execute, EG(fiber_stack_size))) {
815+
if (zend_fiber_init_context(&fiber->context, zend_ce_fiber, zend_fiber_execute, EG(fiber_stack_size)) == FAILURE) {
816816
RETURN_THROWS();
817817
}
818818

Zend/zend_fibers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ struct _zend_fiber {
133133
};
134134

135135
/* These functions may be used to create custom fiber objects using the bundled fiber switching context. */
136-
ZEND_API bool zend_fiber_init_context(zend_fiber_context *context, void *kind, zend_fiber_coroutine coroutine, size_t stack_size);
136+
ZEND_API zend_result zend_fiber_init_context(zend_fiber_context *context, void *kind, zend_fiber_coroutine coroutine, size_t stack_size);
137137
ZEND_API void zend_fiber_destroy_context(zend_fiber_context *context);
138138
ZEND_API void zend_fiber_switch_context(zend_fiber_transfer *transfer);
139139
#ifdef ZEND_CHECK_STACK_LIMIT

0 commit comments

Comments
 (0)