From fa841237dc96eca960771c4ee66813a7e072444e Mon Sep 17 00:00:00 2001 From: Kian Karas Date: Sat, 2 Nov 2024 14:46:15 +0100 Subject: [PATCH] sched/wqueue: fix work_notifier_setup() false failure Be consistent with the datatype used for the 'key'. As the API in in the .h file uses int, I chose to replace uint32_t with int everywhere. This change ensures that work_notifier_setup() will not return a negative value indicating error to the caller, when in fact the notifier was correctly setup. This would happen when work_notifier_setup() had been called 0x8000000 times, and that many keys allocated. --- sched/wqueue/kwork_notifier.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sched/wqueue/kwork_notifier.c b/sched/wqueue/kwork_notifier.c index f915cfa3e72..7230b0d13b7 100644 --- a/sched/wqueue/kwork_notifier.c +++ b/sched/wqueue/kwork_notifier.c @@ -66,7 +66,7 @@ struct work_notifier_entry_s /* Additional payload needed to manage the notification */ - uint32_t key; /* Unique ID for the notification */ + int key; /* Unique ID for the notification */ }; /**************************************************************************** @@ -100,7 +100,7 @@ static dq_queue_t g_notifier_pending; * ****************************************************************************/ -static FAR struct work_notifier_entry_s *work_notifier_find(uint32_t key) +static FAR struct work_notifier_entry_s *work_notifier_find(int key) { FAR struct work_notifier_entry_s *notifier; FAR dq_entry_t *entry; @@ -134,11 +134,11 @@ static FAR struct work_notifier_entry_s *work_notifier_find(uint32_t key) * ****************************************************************************/ -static uint32_t work_notifier_key(void) +static int work_notifier_key(void) { - static uint32_t notifier_key; + static int notifier_key; - if (++notifier_key == 0) + if (++notifier_key <= 0) { notifier_key = 1; }