Skip to content

Commit 3ba2845

Browse files
committed
RETURN_THROWS() where appropriate
Removed a status check that is impossible to be true.
1 parent 6b4a13b commit 3ba2845

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

Zend/zend_fibers.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ ZEND_METHOD(Fiber, start)
497497

498498
if (fiber->status != ZEND_FIBER_STATUS_INIT) {
499499
zend_throw_error(zend_ce_fiber_error, "Cannot start a fiber that has already been started");
500-
return;
500+
RETURN_THROWS();
501501
}
502502

503503
fiber->fci.params = params;
@@ -506,7 +506,7 @@ ZEND_METHOD(Fiber, start)
506506

507507
if (!zend_fiber_init_context(&fiber->context, zend_fiber_execute, EG(fiber_stack_size))) {
508508
zend_throw_error(NULL, "Could not create fiber context");
509-
return;
509+
RETURN_THROWS();
510510
}
511511

512512
fiber->status = ZEND_FIBER_STATUS_RUNNING;
@@ -537,16 +537,12 @@ ZEND_METHOD(Fiber, suspend)
537537

538538
if (UNEXPECTED(!fiber)) {
539539
zend_throw_error(zend_ce_fiber_error, "Cannot suspend outside of a fiber");
540-
return;
540+
RETURN_THROWS();
541541
}
542542

543-
if (UNEXPECTED(fiber->status != ZEND_FIBER_STATUS_RUNNING)) {
544-
if (fiber->status == ZEND_FIBER_STATUS_SHUTDOWN) {
545-
zend_throw_error(zend_ce_fiber_error, "Cannot suspend in a force closed fiber");
546-
} else {
547-
zend_throw_error(zend_ce_fiber_error, "Cannot suspend in a fiber that is not running");
548-
}
549-
return;
543+
if (UNEXPECTED(fiber->status == ZEND_FIBER_STATUS_SHUTDOWN)) {
544+
zend_throw_error(zend_ce_fiber_error, "Cannot suspend in a force closed fiber");
545+
RETURN_THROWS();
550546
}
551547

552548
if (value) {
@@ -570,7 +566,7 @@ ZEND_METHOD(Fiber, suspend)
570566
} else {
571567
zend_throw_fiber_exit();
572568
}
573-
return;
569+
RETURN_THROWS();
574570
}
575571

576572
fiber->status = ZEND_FIBER_STATUS_RUNNING;
@@ -607,7 +603,7 @@ ZEND_METHOD(Fiber, resume)
607603

608604
if (UNEXPECTED(fiber->status != ZEND_FIBER_STATUS_SUSPENDED)) {
609605
zend_throw_error(zend_ce_fiber_error, "Cannot resume a fiber that is not suspended");
610-
return;
606+
RETURN_THROWS();
611607
}
612608

613609
if (value) {
@@ -643,7 +639,7 @@ ZEND_METHOD(Fiber, throw)
643639

644640
if (UNEXPECTED(fiber->status != ZEND_FIBER_STATUS_SUSPENDED)) {
645641
zend_throw_error(zend_ce_fiber_error, "Cannot resume a fiber that is not suspended");
646-
return;
642+
RETURN_THROWS();
647643
}
648644

649645
Z_ADDREF_P(exception);
@@ -735,7 +731,7 @@ ZEND_METHOD(Fiber, getReturn)
735731
}
736732

737733
zend_throw_error(zend_ce_fiber_error, "Cannot get fiber return value: %s", message);
738-
return;
734+
RETURN_THROWS();
739735
}
740736

741737
RETURN_COPY(&fiber->value);

0 commit comments

Comments
 (0)