Skip to content

[Bug] [netdev] ping still applies delay after the last packet and calls rt_thread_delay(0) returning -RT_EINVAL #11865

Closed

Description

@ymj0440

In netdev_cmd_ping(), the loop tries to skip the inter-packet delay on the final ping:

/* if the response time is more than NETDEV_PING_DELAY, no need to delay */
delay_tick = ((rt_tick_get() - start_tick) > NETDEV_PING_DELAY) || (index == times) ? 0 : NETDEV_PING_DELAY;
rt_thread_delay(delay_tick);

Two issues:

  1. The index == times condition is never true inside the loop (index < times), so the delay is still applied after the last packet, contrary to the comment.
  2. When delay_tick becomes 0, rt_thread_delay(0) is still called and returns -RT_EINVAL (invalid argument).

Proposed fix: compute the actual elapsed time, skip the delay on the last packet via index != times - 1, and only call rt_thread_delay() when delay_tick > 0.

Activity

  1. ymj0440 commented on Oct 14, 2026

    @ymj0440
    ContributorAuthor

    /claim

  2. github-actions commented on Oct 14, 2026

    @github-actions

    @ymj0440 has claimed this issue.

  3. github-actions commented on Oct 14, 2026

    @github-actions

    如需认领并处理此 Issue,请评论 /claim。

    To claim and work on this issue, comment /claim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions