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 7371bb570a8ca0b715ec3c8f8a0e337a5b68e276 Author: ouyangxiangzhen <[email protected]> AuthorDate: Thu Mar 12 11:13:46 2026 +0800 sched/wdog: Fix overflow issue if CONFIG_HRTIMER enabled. This commit fixed overflow issue if CONFIG_HRTIMER enabled. Assisted-By: mimo-v2.6-pro Signed-off-by: ouyangxiangzhen <[email protected]> --- sched/wdog/wd_start.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sched/wdog/wd_start.c b/sched/wdog/wd_start.c index 68f0825832e..302d8d787cb 100644 --- a/sched/wdog/wd_start.c +++ b/sched/wdog/wd_start.c @@ -394,8 +394,9 @@ uint64_t wd_timer(const hrtimer_t *timer, uint64_t expired) clock_t tick = div_const(expired, NSEC_PER_TICK); clock_t delay = wd_expiration(tick) - tick; - uint64_t nsec = TICK2NSEC(delay); + uint64_t nsec = delay <= HRTIMER_MAX_DELAY / NSEC_PER_TICK ? + TICK2NSEC(delay) : HRTIMER_MAX_DELAY; - return nsec <= HRTIMER_MAX_DELAY ? nsec : HRTIMER_MAX_DELAY; + return nsec; } #endif
