check usleep() retval

This commit is contained in:
Devaev Maxim
2021-01-21 11:22:04 +03:00
parent c3f98b34f2
commit fa6afb96ce

View File

@@ -221,18 +221,20 @@ static int _vcos_semwait(VCOS_SEMAPHORE_T *sem) {
if (sem_status == VCOS_SUCCESS) { if (sem_status == VCOS_SUCCESS) {
return 0; return 0;
} else if (sem_status != VCOS_EAGAIN || get_now_monotonic() > deadline_ts) { } else if (sem_status != VCOS_EAGAIN || get_now_monotonic() > deadline_ts) {
goto error; break;
}
if (usleep(1000) < 0) {
break;
} }
usleep(1000);
} }
error: switch (sem_status) {
switch (sem_status) { case VCOS_EAGAIN: LOG_ERROR("Can't wait VCOS semaphore: EAGAIN (timeout)"); break;
case VCOS_EAGAIN: LOG_ERROR("Can't wait VCOS semaphore: EAGAIN (timeout)"); break; case VCOS_EINVAL: LOG_ERROR("Can't wait VCOS semaphore: EINVAL"); break;
case VCOS_EINVAL: LOG_ERROR("Can't wait VCOS semaphore: EINVAL"); break; default: LOG_ERROR("Can't wait VCOS semaphore: %d", sem_status); break;
default: LOG_ERROR("Can't wait VCOS semaphore: %d", sem_status); break; }
} return -1;
return -1;
# else # else
return (vcos_semaphore_wait(sem) == VCOS_SUCCESS ? 0 : -1); return (vcos_semaphore_wait(sem) == VCOS_SUCCESS ? 0 : -1);
# endif # endif