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

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

commit e75efc6f437cffc8548736ae625a0b29fcc286c0
Author: makejian <[email protected]>
AuthorDate: Mon Oct 27 22:41:49 2025 +0800

    signal: fix nxsig_sleep misra coverity
    
    The remaining seconds are assigned to an unsigned int without guarding
    the conversion; clamp a negative tv_sec and make the narrowing
    explicit so Coverity can see it is intended.
    
    Signed-off-by: makejian <[email protected]>
    Signed-off-by: zhangyuan29 <[email protected]>
---
 sched/signal/sig_sleep.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sched/signal/sig_sleep.c b/sched/signal/sig_sleep.c
index e892c6cb8f3..c70e9227652 100644
--- a/sched/signal/sig_sleep.c
+++ b/sched/signal/sig_sleep.c
@@ -27,6 +27,7 @@
 #include <nuttx/config.h>
 
 #include <signal.h>
+#include <sys/param.h>
 
 #include <nuttx/clock.h>
 #include <nuttx/signal.h>
@@ -92,7 +93,7 @@ unsigned int nxsig_sleep(unsigned int seconds)
 
       if (ret < 0)
         {
-          remaining = rmtp.tv_sec;
+          remaining = (unsigned int)MAX(rmtp.tv_sec, 0);
           if (remaining < seconds && rmtp.tv_nsec >= 500000000)
             {
               /* Round up */

Reply via email to