anchao commented on code in PR #17640:
URL: https://github.com/apache/nuttx/pull/17640#discussion_r2644617885


##########
sched/wdog/wd_cancel.c:
##########
@@ -61,42 +61,48 @@
 int wd_cancel(FAR struct wdog_s *wdog)
 {
   irqstate_t flags;
-  bool head;
+  bool       reassess = false;
+  int        ret      = -EINVAL;
 
-  flags = spin_lock_irqsave(&g_wdspinlock);
+  if (wdog != NULL)
+    {
+      flags = enter_critical_section();
 
-  /* Make sure that the watchdog is valid and still active. */
+      /* Make sure that the watchdog is valid and still active. */
 
-  if (wdog == NULL || !WDOG_ISACTIVE(wdog))
-    {
-      spin_unlock_irqrestore(&g_wdspinlock, flags);
-      return -EINVAL;
-    }
+      if (WDOG_ISACTIVE(wdog))
+        {
+          /* Prohibit timer interactions with the timer queue until the
+           * cancellation is complete
+           */
 
-  sched_note_wdog(NOTE_WDOG_CANCEL, (FAR void *)wdog->func,
-                  (FAR void *)(uintptr_t)wdog->expired);
+          reassess = list_is_head(&g_wdactivelist, &wdog->node);
 
-  /* Prohibit timer interactions with the timer queue until the
-   * cancellation is complete
-   */
+          /* Now, remove the watchdog from the timer queue */
 
-  head = list_is_head(&g_wdactivelist, &wdog->node);
+          list_delete_fast(&wdog->node);
 
-  /* Now, remove the watchdog from the timer queue */
+          /* Mark the watchdog inactive */
 
-  list_delete(&wdog->node);
+          wdog->func = NULL;
 
-  spin_unlock_irqrestore(&g_wdspinlock, flags);
+          ret = OK;
+        }
 
-  if (head)
-    {
-      /* If the watchdog is at the head of the timer queue, then
-       * we will need to re-adjust the interval timer that will
-       * generate the next interval event.
-       */
+      if (reassess)

Review Comment:
   move line 92 -100 after line 87 and remove init value



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to