Commit 97633aa7 authored by Matthieu Baerts (NGI0)'s avatar Matthieu Baerts (NGI0) Committed by Jakub Kicinski

selftests: mptcp: diag: fix shellcheck warnings

shellcheck recently helped to prevent issues. It is then good to fix the
other harmless issues in order to spot "real" ones later.

Here, two categories of warnings are now ignored:

- SC2317: Command appears to be unreachable. The cleanup() function is
  invoked indirectly via the EXIT trap.

- SC2086: Double quote to prevent globbing and word splitting. This is
  recommended, but the current usage is correct and there is no need to
  do all these modifications to be compliant with this rule.

For the modifications:

  - SC2034: ksft_skip appears unused.
  - SC2046: Quote '$(get_msk_inuse)' to prevent word splitting.
  - SC2006: Use $(...) notation instead of legacy backticks `...`.

Now this script is shellcheck (0.9.0) compliant. We can easily spot new
issues.
Reviewed-by: default avatarMat Martineau <martineau@kernel.org>
Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://lore.kernel.org/r/20240306-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v2-7-bc79e6e5e6a0@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 35bc143a
#!/bin/bash #!/bin/bash
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# Double quotes to prevent globbing and word splitting is recommended in new
# code but we accept it, especially because there were too many before having
# address all other issues detected by shellcheck.
#shellcheck disable=SC2086
. "$(dirname "${0}")/mptcp_lib.sh" . "$(dirname "${0}")/mptcp_lib.sh"
ns="" ns=""
ksft_skip=4
test_cnt=1 test_cnt=1
timeout_poll=30 timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1)) timeout_test=$((timeout_poll * 2 + 1))
...@@ -24,6 +28,8 @@ flush_pids() ...@@ -24,6 +28,8 @@ flush_pids()
done done
} }
# This function is used in the cleanup trap
#shellcheck disable=SC2317
cleanup() cleanup()
{ {
ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGKILL &>/dev/null ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGKILL &>/dev/null
...@@ -174,7 +180,7 @@ chk_msk_inuse() ...@@ -174,7 +180,7 @@ chk_msk_inuse()
expected=$((expected + listen_nr)) expected=$((expected + listen_nr))
for _ in $(seq 10); do for _ in $(seq 10); do
if [ $(get_msk_inuse) -eq $expected ];then if [ "$(get_msk_inuse)" -eq $expected ]; then
break break
fi fi
sleep 0.1 sleep 0.1
...@@ -260,7 +266,7 @@ chk_msk_inuse 0 "1->0" ...@@ -260,7 +266,7 @@ chk_msk_inuse 0 "1->0"
chk_msk_cestab 0 "1->0" chk_msk_cestab 0 "1->0"
NR_CLIENTS=100 NR_CLIENTS=100
for I in `seq 1 $NR_CLIENTS`; do for I in $(seq 1 $NR_CLIENTS); do
echo "a" | \ echo "a" | \
timeout ${timeout_test} \ timeout ${timeout_test} \
ip netns exec $ns \ ip netns exec $ns \
...@@ -269,7 +275,7 @@ for I in `seq 1 $NR_CLIENTS`; do ...@@ -269,7 +275,7 @@ for I in `seq 1 $NR_CLIENTS`; do
done done
mptcp_lib_wait_local_port_listen $ns $((NR_CLIENTS + 10001)) mptcp_lib_wait_local_port_listen $ns $((NR_CLIENTS + 10001))
for I in `seq 1 $NR_CLIENTS`; do for I in $(seq 1 $NR_CLIENTS); do
echo "b" | \ echo "b" | \
timeout ${timeout_test} \ timeout ${timeout_test} \
ip netns exec $ns \ ip netns exec $ns \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment