Skip to content

Commit b45d6d6

Browse files
queue test: add counter overflow protect
without this fix test_equeue_break_no_windup was failing on IAR
1 parent 6440aea commit b45d6d6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

TESTS/events/equeue/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ static void pass_func(void *eh)
3939

4040
static void simple_func(void *p)
4141
{
42-
(*(reinterpret_cast<uint8_t *>(p)))++;
42+
uint8_t *d = reinterpret_cast<uint8_t *>(p);
43+
if (*d < 255) {
44+
(*d)++;
45+
}
4346
}
4447

4548
static void sloth_func(void *p)

UNITTESTS/events/equeue/test_equeue.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ static void pass_func(void *eh)
4545

4646
static void simple_func(void *p)
4747
{
48-
(*(reinterpret_cast<uint8_t *>(p)))++;
48+
uint8_t *d = reinterpret_cast<uint8_t *>(p);
49+
if (*d < 255) {
50+
(*d)++;
51+
}
4952
}
5053

5154
static void sloth_func(void *p)

0 commit comments

Comments
 (0)