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:
wangchengdong
2025-11-03 17:11:16 +08:00
committed by archer
parent e7ad870f18
commit 522f32f7ef

View File

@@ -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)