From babef3d102509792aa01050c15b68bc2a18800ac Mon Sep 17 00:00:00 2001 From: wushenhui Date: Tue, 22 Jul 2025 16:21:26 +0800 Subject: [PATCH] sched/wqueue: Fix work_cancel() to return -ENOENT when no such work is queued. Fix work_cancel() to return -ENOENT when no such work is queued. Signed-off-by: wushenhui --- sched/wqueue/kwork_cancel.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sched/wqueue/kwork_cancel.c b/sched/wqueue/kwork_cancel.c index 8a8bc6036b158..2196dad7a0fa5 100644 --- a/sched/wqueue/kwork_cancel.c +++ b/sched/wqueue/kwork_cancel.c @@ -45,8 +45,9 @@ static int work_qcancel(FAR struct kwork_wqueue_s *wqueue, bool sync, FAR struct work_s *work) { - irqstate_t flags; FAR sem_t *sync_wait = NULL; + irqstate_t flags; + int ret = 0; if (wqueue == NULL || work == NULL) { @@ -71,6 +72,10 @@ static int work_qcancel(FAR struct kwork_wqueue_s *wqueue, bool sync, work_timer_reset(wqueue); } } + else + { + ret = -ENOENT; + } /* Note that cancel_sync can not be called in the interrupt * context and the idletask context. @@ -102,7 +107,7 @@ static int work_qcancel(FAR struct kwork_wqueue_s *wqueue, bool sync, nxsem_wait_uninterruptible(sync_wait); } - return 0; + return ret; } /****************************************************************************