test: Shellcheck - correct rule: Iterating over ls

Correct shellcheck rule SC2045: Iterating over ls output is fragile. Use globs.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: I436878774d6f86c23b1c5cf5220da297053f03e2
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477397
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Maciej Wawryk 2019-12-10 07:58:35 +01:00 committed by Tomasz Zawadzki
parent a291cb0606
commit 19e48a66a4
5 changed files with 10 additions and 8 deletions

View File

@ -240,7 +240,7 @@ if hash shellcheck 2>/dev/null; then
# go to: https://trello.com/c/29Z90j1W
# Error descriptions can also be found at: https://github.com/koalaman/shellcheck/wiki
# This SHCK_EXCLUDE list is out "to do" and we work to fix all of this errors.
SHCK_EXCLUDE="SC2002,SC2010,SC2034,SC2045"
SHCK_EXCLUDE="SC2002,SC2010,SC2034"
# SPDK fails some error checks which have been deprecated in later versions of shellcheck.
# We will not try to fix these error checks, but instead just leave the error types here
# so that we can still run with older versions of shellcheck.

View File

@ -76,7 +76,7 @@ function install_iscsi_adm()
git -C open-iscsi-install/open-iscsi config user.email none
git -C open-iscsi-install/open-iscsi checkout 86e8892
for patch in $(ls open-iscsi-install/patches); do
for patch in open-iscsi-install/patches/*; do
git -C open-iscsi-install/open-iscsi am ../patches/$patch
done
sed -i '427s/.*/-1);/' open-iscsi-install/open-iscsi/usr/session_info.c

View File

@ -28,13 +28,13 @@ fi
$rpc_py bdev_get_bdevs
$rpc_py bdev_nvme_get_controllers
for ns in $(ls /dev/spdk/nvme?n?); do
for ns in /dev/spdk/nvme?n?; do
${NVME_CMD} get-ns-id $ns
${NVME_CMD} id-ns $ns
${NVME_CMD} list-ns $ns
done
for ctrlr in $(ls /dev/spdk/nvme?); do
for ctrlr in /dev/spdk/nvme?; do
${NVME_CMD} id-ctrl $ctrlr
${NVME_CMD} list-ctrl $ctrlr
${NVME_CMD} fw-log $ctrlr

View File

@ -131,9 +131,11 @@ function get_available_rdma_ips()
function get_rdma_if_list()
{
for nic_type in $(ls /sys/class/infiniband); do
for nic_name in $(ls /sys/class/infiniband/${nic_type}/device/net); do
echo "$nic_name"
for nic_type in /sys/class/infiniband/*; do
[[ -e "$nic_type" ]] || break
for nic_name in /sys/class/infiniband/"$(basename ${nic_type})"/device/net/*; do
[[ -e "$nic_name" ]] || break
basename "$nic_name"
done
done
}

View File

@ -1123,7 +1123,7 @@ function at_app_exit()
# Kill vhost application
notice "killing vhost app"
for vhost_name in $(ls $TARGET_DIR); do
for vhost_name in "$TARGET_DIR"/*; do
vhost_kill $vhost_name
done