This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 7b47b9de17b064f7a2e419b364927af2a1393545
Author: ouyangxiangzhen <[email protected]>
AuthorDate: Thu Jan 8 11:22:11 2026 +0800

    sched/wdog: Simplify the wd_gettime.
    
    This commit simplified the wd_gettime.
    
    Signed-off-by: ouyangxiangzhen <[email protected]>
---
 sched/wdog/wd_gettime.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/sched/wdog/wd_gettime.c b/sched/wdog/wd_gettime.c
index 95327a0bbf5..5ebdcfc3c4a 100644
--- a/sched/wdog/wd_gettime.c
+++ b/sched/wdog/wd_gettime.c
@@ -56,23 +56,21 @@ sclock_t wd_gettime(FAR struct wdog_s *wdog)
 {
   irqstate_t flags;
   clock_t    expired;
+  bool       is_active;
   sclock_t   delay = 0;
 
-  if (wdog != NULL)
+  if (wdog != NULL && WDOG_ISACTIVE(wdog))
     {
-      flags   = enter_critical_section();
-      if (WDOG_ISACTIVE(wdog))
-        {
-          expired = wdog->expired;
-          leave_critical_section(flags);
+      flags     = enter_critical_section();
+      is_active = WDOG_ISACTIVE(wdog);
+      expired   = wdog->expired;
+      leave_critical_section(flags);
 
+      if (is_active)
+        {
           delay = (sclock_t)(expired - clock_systime_ticks());
           delay = delay >= 0 ? delay : 0;
         }
-      else
-        {
-          leave_critical_section(flags);
-        }
     }
 
   return delay;

Reply via email to