Skip to content

Commit 9a350fe

Browse files
committed
better error handling
1 parent bac72fb commit 9a350fe

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

Zend/zend.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -833,11 +833,9 @@ static void zend_timer_create() /* {{{ */
833833
sev.sigev_signo = SIGIO;
834834
sev.sigev_notify_thread_id = (pid_t) syscall(SYS_gettid);
835835

836-
int errn = timer_create(CLOCK_THREAD_CPUTIME_ID, &sev, &EG(timer));
837-
if (errn != 0) {
836+
if (timer_create(CLOCK_THREAD_CPUTIME_ID, &sev, &EG(timer)) != 0) {
838837
EG(timer) = 0;
839-
840-
zend_strerror_noreturn(E_ERROR, errn, "Could not create timer");
838+
zend_strerror_noreturn(E_ERROR, errno, "Could not create timer");
841839
}
842840

843841
# ifdef TIMER_DEBUG
@@ -865,10 +863,11 @@ static void zend_thread_shutdown_handler(void) { /* {{{ */
865863
# ifdef ZEND_TIMER
866864
timer_t timer = EG(timer);
867865

868-
if (timer == 0) return;
866+
if (timer == 0)
867+
zend_error_noreturn(E_ERROR, "Could not c timer");
869868

870-
int errn = timer_delete(EG(timer));
871-
if (errn != 0) zend_strerror_noreturn(E_ERROR, errn, "Could not delete timer");
869+
if (timer_delete(timer) != 0)
870+
zend_strerror_noreturn(E_ERROR, errno, "Could not delete timer");
872871

873872
# ifdef TIMER_DEBUG
874873
fprintf(stderr, "Timer %#jx deleted on thread %d\n", (uintmax_t) EG(timer), (pid_t) syscall(SYS_gettid));

Zend/zend_execute_API.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ static void zend_timer_settime(zend_long seconds) /* {{{ }*/
397397
its.it_value.tv_sec = seconds;
398398
its.it_value.tv_nsec = its.it_interval.tv_sec = its.it_interval.tv_nsec = 0;
399399

400-
int errn = timer_settime(timer, 0, &its, NULL);
401-
if (errn != 0) zend_strerror_noreturn(E_ERROR, errn, "Could not set timer");
400+
if (timer_settime(timer, 0, &its, NULL) != 0)
401+
zend_strerror_noreturn(E_ERROR, errno, "Could not set timer");
402402

403403
# ifdef TIMER_DEBUG
404404
fprintf(stderr, "Timer %#jx set on thread %d (%ld seconds)\n", (uintmax_t) timer, (pid_t) syscall(SYS_gettid), seconds);

0 commit comments

Comments
 (0)