You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2026/09/10 19:00:25 UTC
(nuttx) 03/04: sched/cpuload: fix hardcoded 100000 should be USEC_PER_SEC
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 1a7a1891364b729eda2835992de0d82bd7611971
Author: yushuailong <yy...@qq.com>
AuthorDate: Thu Sep 10 15:56:08 2026 +0800
sched/cpuload: fix hardcoded 100000 should be USEC_PER_SEC
Replace a literal 100000 with the USEC_PER_SEC macro in the oneshot
timer restart calculation. This bug causes incorrect timeout values
when CONFIG_SCHED_CPULOAD_TICKSPERSEC=1, though defaults are not
affected. Present since 2016 (commit 300361539a).
Assisted-by: OpenAI Codex
Signed-off-by: yushuailong <yy...@qq.com>
---
sched/sched/sched_cpuload_oneshot.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sched/sched/sched_cpuload_oneshot.c b/sched/sched/sched_cpuload_oneshot.c
index 1326a32facc..b17da3c2313 100644
--- a/sched/sched/sched_cpuload_oneshot.c
+++ b/sched/sched/sched_cpuload_oneshot.c
@@ -194,7 +194,7 @@ static void nxsched_oneshot_start(void)
/* Then re-start the oneshot timer */
secs = USEC2SEC(usecs);
- usecs -= 100000 * secs;
+ usecs -= USEC_PER_SEC * secs;
ts.tv_sec = secs;
ts.tv_nsec = 1000 * usecs;