Skip to content

Commit da699e4

Browse files
committed
samples: net: zperf: UDP download cmd params incorrectly checked
The "zperf udp download" optional port parameter was not properly checked, the default port check branch was never reached. Fix also the same issue in tcp download command. Coverity-CID: 188881 Fixes #10758 Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 24da652 commit da699e4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

samples/net/zperf/src/zperf_shell.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,12 @@ static int cmd_udp_download(const struct shell *shell, size_t argc,
307307

308308
do_init(shell);
309309

310-
if (argc < 2 || shell_help_requested(shell)) {
310+
if (shell_help_requested(shell)) {
311311
shell_help_print(shell, NULL, 0);
312312
return -ENOEXEC;
313313
}
314314

315-
if (argc > 1) {
315+
if (argc >= 2) {
316316
port = strtoul(argv[start + 1], NULL, 10);
317317
} else {
318318
port = DEF_PORT;
@@ -975,12 +975,12 @@ static int cmd_tcp_download(const struct shell *shell, size_t argc,
975975

976976
do_init(shell);
977977

978-
if (argc < 2 || shell_help_requested(shell)) {
978+
if (shell_help_requested(shell)) {
979979
shell_help_print(shell, NULL, 0);
980980
return -ENOEXEC;
981981
}
982982

983-
if (argc > 1) {
983+
if (argc >= 2) {
984984
port = strtoul(argv[1], NULL, 10);
985985
} else {
986986
port = DEF_PORT;
@@ -1108,7 +1108,7 @@ SHELL_CREATE_STATIC_SUBCMD_SET(zperf_cmd_tcp)
11081108
,
11091109
cmd_tcp_upload2),
11101110
SHELL_CMD(download, NULL,
1111-
"<port>\n"
1111+
"[<port>]\n"
11121112
"Example: tcp download 5001\n",
11131113
cmd_tcp_download),
11141114
SHELL_SUBCMD_SET_END
@@ -1148,7 +1148,7 @@ SHELL_CREATE_STATIC_SUBCMD_SET(zperf_cmd_udp)
11481148
,
11491149
cmd_udp_upload2),
11501150
SHELL_CMD(download, NULL,
1151-
"<port>\n"
1151+
"[<port>]\n"
11521152
"Example: udp download 5001\n",
11531153
cmd_udp_download),
11541154
SHELL_SUBCMD_SET_END

0 commit comments

Comments
 (0)