Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

events - Fixed overflow of timeout on STM32F4 #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

geky
Copy link
Contributor

@geky geky commented Jan 10, 2017

For equeue_sema_wait, -1 is used to indicate an infinite wait. This wasn't handled in the nonrtos implementation and caused undefined/weird behaviour after an overflow on integer multiplication.

On most boards, the infinite wait would return after ~50 days, on the STM32F4 the timeout killed all other timeouts for some reason.

tested on NUCLEO_F401RE
mirrored on ARMmbed/mbed-os#3550

For equeue_sema_wait, -1 is used to indicate an infinite wait.
This wasn't handled in the nonrtos implementation and caused
undefined/weird behaviour after an overflow on integer multiplication.

On most boards, the infinite wait would return after ~50 days, on the
STM32F4 the timeout killed all other timeouts for some reason.
@@ -110,7 +110,9 @@ static void equeue_sema_timeout(equeue_sema_t *s) {
bool equeue_sema_wait(equeue_sema_t *s, int ms) {
int signal = 0;
Timeout timeout;
timeout.attach_us(s, equeue_sema_timeout, ms*1000);
if (ms < 0) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't be ms > 0 ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants