Repository navigation
fix(netdev): correct ping delay logic for last packet and avoid rt_thread_delay(0) - #11866
Conversation
…read_delay(0) The 'index == times' condition in the delay_tick calculation is never true, so the delay was still applied after the last ping, contrary to the comment. Skip the delay on the final ping by checking 'index != times - 1'. Also only call rt_thread_delay() when delay_tick > 0, since passing 0 returns -RT_EINVAL.
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-10-14 10:14 CST)
📝 Review Instructions
|
|
摘要 Summary
修复
netdev_cmd_ping()中 ping 间隔时延的两处缺陷:index == times恒为假,导致最后一次 ping 后仍会补时延,与原注释意图不符;delay_tick为 0 时仍调用rt_thread_delay(0),该调用会返回-RT_EINVAL。修改为:记录实际耗时
cost_tick,用index != times - 1判断是否最后一轮,且仅当delay_tick > 0时才调用rt_thread_delay()。Fixes #11865
改动文件 Changes
components/net/netdev/src/netdev.c(+14/-4)检查清单 Check List