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-apps.git

commit 3b99721dbbaee00f3af0cd99bf15eb9ba96e095e
Author: yangjianqing <[email protected]>
AuthorDate: Tue May 26 19:13:02 2026 +0800

    netutils/iperf: fix `iperf -a` getopt to actually call iperf_stop()
    
    `iperf_main.c` declared the short option string as
    `"sua:c:B:p:i:t:"` -- the trailing colon on `-a` made it an
    *argument-taking* option. As a result `iperf -a` (no value
    attached) silently fell through to getopt's missing-argument
    handler, which only printed USAGE and exited with EXIT_FAILURE.
    
    Net effect: the `-a` (abort) feature was dead. Users typing
    `iperf -a` to stop a running iperf task got USAGE and the task
    kept running, because `iperf_stop()` was never called.
    
    Drop the colon so `-a` is parsed as a flag. The existing
    post-getopt code already does the right thing:
    
      if (iperf.abort != 0)
        {
          iperf_stop();
          printf("ERROR: abort: %d\n", iperf.abort);
          goto out;
        }
    
    After the fix `iperf -a` walks the global ctrl list (mutex-
    protected), sets `ctrl->finish = true` on each entry, prints
    `ERROR: abort: 1`, and falls through to USAGE via the `out:`
    label. A regression test in tests/net/iperf/iperfargs asserts the
    `ERROR: abort: 1` marker so a future change cannot quietly
    re-introduce the broken arg-taking form.
    
    Signed-off-by: yangjianqing <[email protected]>
    Assisted-by: Kiro:claude-opus-4
---
 netutils/iperf/iperf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/netutils/iperf/iperf_main.c b/netutils/iperf/iperf_main.c
index a67d1f3fd..5e4eb7f71 100644
--- a/netutils/iperf/iperf_main.c
+++ b/netutils/iperf/iperf_main.c
@@ -175,7 +175,7 @@ int main(int argc, FAR char *argv[])
   cfg.sport = IPERF_DEFAULT_PORT;
   cfg.dport = IPERF_DEFAULT_PORT;
 
-  while ((opt = getopt_long(argc, argv, "sua:c:B:p:i:t:",
+  while ((opt = getopt_long(argc, argv, "suac:B:p:i:t:",
                             loptions, NULL)) != -1)
     {
       switch (opt)

Reply via email to