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 a5f5ab185c2e71c03f47063adadeb4fcd97d5dc6
Author: ouyangxiangzhen <[email protected]>
AuthorDate: Mon Oct 13 11:31:04 2025 +0800

    driver/timers: Fix coverity uninitialzed timespec.
    
    This commit fixed uninitialized timespec.
    
    Signed-off-by: ouyangxiangzhen <[email protected]>
---
 include/nuttx/timers/oneshot.h | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/include/nuttx/timers/oneshot.h b/include/nuttx/timers/oneshot.h
index b2d5b35f0a3..be5b48dbdf2 100644
--- a/include/nuttx/timers/oneshot.h
+++ b/include/nuttx/timers/oneshot.h
@@ -508,7 +508,10 @@ int oneshot_start_absolute(FAR struct oneshot_lowerhalf_s 
*lower,
       up_irq_restore(flags);
     }
 #else
-  struct timespec curr;
+  struct timespec curr =
+  {
+    0
+  };
 
   /* Some timer drivers may not have current() function.
    * Since only arch_alarm uses the function, it should be OK.
@@ -534,7 +537,10 @@ int oneshot_tick_max_delay(FAR struct oneshot_lowerhalf_s 
*lower,
   clkcnt_t max = lower->ops->max_delay(lower);
   *tick = clkcnt_max_tick(max, lower->frequency);
 #else
-  struct timespec ts;
+  struct timespec ts =
+  {
+    0
+  };
 
   ret = lower->ops->max_delay(lower, &ts);
   *tick = clock_time2ticks(&ts);
@@ -601,7 +607,10 @@ int oneshot_tick_current(FAR struct oneshot_lowerhalf_s 
*lower,
   cnt   -= sec * freq;
   *tick  = sec * TICK_PER_SEC + oneshot_delta_cnt2tick(lower, cnt);
 #else
-  struct timespec ts;
+  struct timespec ts =
+  {
+    0
+  };
 
   /* Some timer drivers may not have current() function.
    * Since only arch_alarm uses the function, it should be OK.
@@ -667,7 +676,10 @@ int oneshot_tick_cancel(FAR struct oneshot_lowerhalf_s 
*lower,
   lower->ops->cancel(lower);
   oneshot_tick_current(lower, tick);
 #else
-  struct timespec ts;
+  struct timespec ts =
+  {
+    0
+  };
 
   ret = lower->ops->cancel(lower, &ts);
 

Reply via email to