test: Shellcheck - correct rule: read lines rather than words

Correct shellcheck rule SC2013: To read lines rather than
words, pipe/redirect to a 'while read' loop.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: I01c0dcf045fc131ce0cfa672e5ede0b881a47406
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471433
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Maciej Wawryk 2019-10-16 07:35:00 +02:00 committed by Tomasz Zawadzki
parent e0f2a6e3ea
commit c73eb6a02a
2 changed files with 25 additions and 17 deletions

View File

@ -241,7 +241,7 @@ if hash shellcheck 2>/dev/null; then
# Error descriptions can also be found at: https://github.com/koalaman/shellcheck/wiki # 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. # This SHCK_EXCLUDE list is out "to do" and we work to fix all of this errors.
SHCK_EXCLUDE="SC1083,SC2002,SC2004,\ SHCK_EXCLUDE="SC1083,SC2002,SC2004,\
SC2010,SC2012,SC2013,SC2016,SC2034,SC2045,SC2046,SC2068,SC2086,SC2089,SC2090,\ SC2010,SC2012,SC2016,SC2034,SC2045,SC2046,SC2068,SC2086,SC2089,SC2090,\
SC2097,SC2098,SC2103,SC2115,SC2116,SC2119,SC2120,SC2121,SC2124,SC2126,SC2128,\ SC2097,SC2098,SC2103,SC2115,SC2116,SC2119,SC2120,SC2121,SC2124,SC2126,SC2128,\
SC2129,SC2140,SC2142,SC2143,SC2148,SC2152,SC2153,SC2154,SC2155,\ SC2129,SC2140,SC2142,SC2143,SC2148,SC2152,SC2153,SC2154,SC2155,\
SC2162,SC2164,SC2165,SC2166,SC2167,\ SC2162,SC2164,SC2165,SC2166,SC2167,\

View File

@ -233,7 +233,8 @@ function configure_linux_pci {
grep "PCI_DEVICE_ID_INTEL_IOAT" $rootdir/include/spdk/pci_ids.h \ grep "PCI_DEVICE_ID_INTEL_IOAT" $rootdir/include/spdk/pci_ids.h \
| awk -F"x" '{print $2}' > $TMP | awk -F"x" '{print $2}' > $TMP
for dev_id in $(cat $TMP); do while IFS= read -r dev_id
do
for bdf in $(iter_all_pci_dev_id 8086 $dev_id); do for bdf in $(iter_all_pci_dev_id 8086 $dev_id); do
if ! pci_can_use $bdf; then if ! pci_can_use $bdf; then
pci_dev_echo "$bdf" "Skipping un-whitelisted I/OAT device" pci_dev_echo "$bdf" "Skipping un-whitelisted I/OAT device"
@ -242,7 +243,7 @@ function configure_linux_pci {
linux_bind_driver "$bdf" "$driver_name" linux_bind_driver "$bdf" "$driver_name"
done done
done done < $TMP
rm $TMP rm $TMP
# virtio # virtio
@ -251,7 +252,8 @@ function configure_linux_pci {
grep "PCI_DEVICE_ID_VIRTIO" $rootdir/include/spdk/pci_ids.h \ grep "PCI_DEVICE_ID_VIRTIO" $rootdir/include/spdk/pci_ids.h \
| awk -F"x" '{print $2}' > $TMP | awk -F"x" '{print $2}' > $TMP
for dev_id in $(cat $TMP); do while IFS= read -r dev_id
do
for bdf in $(iter_all_pci_dev_id 1af4 $dev_id); do for bdf in $(iter_all_pci_dev_id 1af4 $dev_id); do
if ! pci_can_use $bdf; then if ! pci_can_use $bdf; then
pci_dev_echo "$bdf" "Skipping un-whitelisted Virtio device at $bdf" pci_dev_echo "$bdf" "Skipping un-whitelisted Virtio device at $bdf"
@ -268,7 +270,7 @@ function configure_linux_pci {
linux_bind_driver "$bdf" "$driver_name" linux_bind_driver "$bdf" "$driver_name"
done done
done done < $TMP
rm $TMP rm $TMP
# VMD # VMD
@ -277,7 +279,8 @@ function configure_linux_pci {
grep "PCI_DEVICE_ID_INTEL_VMD" $rootdir/include/spdk/pci_ids.h \ grep "PCI_DEVICE_ID_INTEL_VMD" $rootdir/include/spdk/pci_ids.h \
| awk -F"x" '{print $2}' > $TMP | awk -F"x" '{print $2}' > $TMP
for dev_id in $(cat $TMP); do while IFS= read -r dev_id
do
for bdf in $(iter_pci_dev_id 8086 $dev_id); do for bdf in $(iter_pci_dev_id 8086 $dev_id); do
if [[ -z "$PCI_WHITELIST" ]] || ! pci_can_use $bdf; then if [[ -z "$PCI_WHITELIST" ]] || ! pci_can_use $bdf; then
echo "Skipping un-whitelisted VMD device at $bdf" echo "Skipping un-whitelisted VMD device at $bdf"
@ -287,7 +290,7 @@ function configure_linux_pci {
linux_bind_driver "$bdf" "$driver_name" linux_bind_driver "$bdf" "$driver_name"
echo " VMD generic kdrv: " "$bdf" "$driver_name" echo " VMD generic kdrv: " "$bdf" "$driver_name"
done done
done done < $TMP
rm $TMP rm $TMP
echo "1" > "/sys/bus/pci/rescan" echo "1" > "/sys/bus/pci/rescan"
@ -439,7 +442,8 @@ function reset_linux_pci {
check_for_driver ioatdma check_for_driver ioatdma
driver_loaded=$? driver_loaded=$?
set -e set -e
for dev_id in $(cat $TMP); do while IFS= read -r dev_id
do
for bdf in $(iter_all_pci_dev_id 8086 $dev_id); do for bdf in $(iter_all_pci_dev_id 8086 $dev_id); do
if ! pci_can_use $bdf; then if ! pci_can_use $bdf; then
pci_dev_echo "$bdf" "Skipping un-whitelisted I/OAT device" pci_dev_echo "$bdf" "Skipping un-whitelisted I/OAT device"
@ -451,7 +455,7 @@ function reset_linux_pci {
linux_unbind_driver "$bdf" linux_unbind_driver "$bdf"
fi fi
done done
done done < $TMP
rm $TMP rm $TMP
# virtio # virtio
@ -465,7 +469,8 @@ function reset_linux_pci {
# virtio-pci but just virtio_scsi instead. Also need to make sure we get the # virtio-pci but just virtio_scsi instead. Also need to make sure we get the
# underscore vs. dash right in the virtio_scsi name. # underscore vs. dash right in the virtio_scsi name.
modprobe virtio-pci || true modprobe virtio-pci || true
for dev_id in $(cat $TMP); do while IFS= read -r dev_id
do
for bdf in $(iter_all_pci_dev_id 1af4 $dev_id); do for bdf in $(iter_all_pci_dev_id 1af4 $dev_id); do
if ! pci_can_use $bdf; then if ! pci_can_use $bdf; then
pci_dev_echo "$bdf" "Skipping un-whitelisted Virtio device at" pci_dev_echo "$bdf" "Skipping un-whitelisted Virtio device at"
@ -473,7 +478,7 @@ function reset_linux_pci {
fi fi
linux_bind_driver "$bdf" virtio-pci linux_bind_driver "$bdf" virtio-pci
done done
done done < $TMP
rm $TMP rm $TMP
# VMD # VMD
@ -486,7 +491,8 @@ function reset_linux_pci {
check_for_driver vmd check_for_driver vmd
driver_loaded=$? driver_loaded=$?
set -e set -e
for dev_id in $(cat $TMP); do while IFS= read -r dev_id
do
for bdf in $(iter_pci_dev_id 8086 $dev_id); do for bdf in $(iter_pci_dev_id 8086 $dev_id); do
if ! pci_can_use $bdf; then if ! pci_can_use $bdf; then
echo "Skipping un-whitelisted VMD device at $bdf" echo "Skipping un-whitelisted VMD device at $bdf"
@ -498,7 +504,7 @@ function reset_linux_pci {
linux_unbind_driver "$bdf" linux_unbind_driver "$bdf"
fi fi
done done
done done < $TMP
rm $TMP rm $TMP
echo "1" > "/sys/bus/pci/rescan" echo "1" > "/sys/bus/pci/rescan"
@ -631,16 +637,18 @@ function configure_freebsd_pci {
# IOAT # IOAT
grep "PCI_DEVICE_ID_INTEL_IOAT" $rootdir/include/spdk/pci_ids.h \ grep "PCI_DEVICE_ID_INTEL_IOAT" $rootdir/include/spdk/pci_ids.h \
| awk -F"x" '{print $2}' > $TMP | awk -F"x" '{print $2}' > $TMP
for dev_id in $(cat $TMP); do while IFS= read -r dev_id
do
GREP_STR="${GREP_STR}\|chip=0x${dev_id}8086" GREP_STR="${GREP_STR}\|chip=0x${dev_id}8086"
done done < $TMP
# VMD # VMD
grep "PCI_DEVICE_ID_INTEL_VMD" $rootdir/include/spdk/pci_ids.h \ grep "PCI_DEVICE_ID_INTEL_VMD" $rootdir/include/spdk/pci_ids.h \
| awk -F"x" '{print $2}' > $TMP | awk -F"x" '{print $2}' > $TMP
for dev_id in $(cat $TMP); do while IFS= read -r dev_id
do
GREP_STR="${GREP_STR}\|chip=0x${dev_id}8086" GREP_STR="${GREP_STR}\|chip=0x${dev_id}8086"
done done < $TMP
AWK_PROG="{if (count > 0) printf \",\"; printf \"%s:%s:%s\",\$2,\$3,\$4; count++}" AWK_PROG="{if (count > 0) printf \",\"; printf \"%s:%s:%s\",\$2,\$3,\$4; count++}"
echo $AWK_PROG > $TMP echo $AWK_PROG > $TMP