This is an automated email from the ASF dual-hosted git repository.
archer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 190daef2bf2 sched/wdog: Use list_in_list() to detect active watchdogs
190daef2bf2 is described below
commit 190daef2bf2c5cdc60ad035e7a811a5c606c8500
Author: wangchengdong <[email protected]>
AuthorDate: Thu Nov 6 19:01:38 2025 +0800
sched/wdog: Use list_in_list() to detect active watchdogs
Use list_in_list() to determine whether a watchdog is active,
eliminating the need to set the watchdog function pointer to NULL
as an indicator of inactivity.
Signed-off-by: Chengdong Wang [email protected]
---
include/nuttx/wdog.h | 2 +-
sched/wdog/wd_cancel.c | 3 ---
sched/wdog/wd_start.c | 3 ---
3 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/include/nuttx/wdog.h b/include/nuttx/wdog.h
index 19108f5c834..fc935b3ba3c 100644
--- a/include/nuttx/wdog.h
+++ b/include/nuttx/wdog.h
@@ -39,7 +39,7 @@
* Pre-processor Definitions
****************************************************************************/
-#define WDOG_ISACTIVE(w) ((w)->func != NULL)
+#define WDOG_ISACTIVE(w) (list_in_list(&((w)->node)))
/* The maximum delay tick are supposed to be CLOCK_MAX >> 1.
* However, if there are expired wdog timers in the wdog queue,
diff --git a/sched/wdog/wd_cancel.c b/sched/wdog/wd_cancel.c
index ae8f80cc7c9..143c159010e 100644
--- a/sched/wdog/wd_cancel.c
+++ b/sched/wdog/wd_cancel.c
@@ -86,9 +86,6 @@ int wd_cancel(FAR struct wdog_s *wdog)
list_delete(&wdog->node);
- /* Mark the watchdog inactive */
-
- wdog->func = NULL;
spin_unlock_irqrestore(&g_wdspinlock, flags);
if (head)
diff --git a/sched/wdog/wd_start.c b/sched/wdog/wd_start.c
index 135c8326603..20098630ace 100644
--- a/sched/wdog/wd_start.c
+++ b/sched/wdog/wd_start.c
@@ -162,7 +162,6 @@ static inline_function void wd_expiration(clock_t ticks)
func = wdog->func;
arg = wdog->arg;
- wdog->func = NULL;
/* Execute the watchdog function */
@@ -310,7 +309,6 @@ int wd_start_abstick(FAR struct wdog_s *wdog, clock_t ticks,
{
reassess |= list_is_head(&g_wdactivelist, &wdog->node);
list_delete(&wdog->node);
- wdog->func = NULL;
}
reassess |= wd_insert(wdog, ticks, wdentry, arg);
@@ -337,7 +335,6 @@ int wd_start_abstick(FAR struct wdog_s *wdog, clock_t ticks,
if (WDOG_ISACTIVE(wdog))
{
list_delete(&wdog->node);
- wdog->func = NULL;
}
wd_insert(wdog, ticks, wdentry, arg);