mirror of
https://github.com/apache/nuttx.git
synced 2026-03-23 22:43:57 +08:00
sched/event: Fix uninitialized need_switch flag issue in event_post()
The `need_switch` flag was not initialized in `event_post()`. Since it is
a local variable, it could contain a random non-zero value, leading to
incorrect behavior.
In addition, this patch also fixes an issue where the event clearing
operation in `event_post()` was not performed correctly.
Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
This commit is contained in:
@@ -68,7 +68,7 @@ int nxevent_post(FAR nxevent_t *event, nxevent_mask_t events,
|
||||
dq_queue_t *waitlist;
|
||||
bool waitall;
|
||||
bool postall;
|
||||
bool need_switch;
|
||||
bool need_switch = false;
|
||||
|
||||
if (event == NULL)
|
||||
{
|
||||
@@ -133,11 +133,11 @@ int nxevent_post(FAR nxevent_t *event, nxevent_mask_t events,
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (clear)
|
||||
{
|
||||
event->events &= ~clear;
|
||||
}
|
||||
if (clear != 0)
|
||||
{
|
||||
event->events &= ~clear;
|
||||
}
|
||||
|
||||
if (need_switch)
|
||||
|
||||
Reference in New Issue
Block a user