Commit 074df1d8 authored by Pawel Kaminski's avatar Pawel Kaminski Committed by Jim Harris
Browse files

test: Shellcheck - apply rule SC2155



Declare and assign separately to avoid masking return values.

Signed-off-by: default avatarPawel Kaminski <pawelx.kaminski@intel.com>
Change-Id: Ib90598e4268911a3056e8a0baa7d541edaa29b91
Signed-off-by: default avatarPawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472287


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent c9c57691
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -243,7 +243,7 @@ if hash shellcheck 2>/dev/null; then
	SHCK_EXCLUDE="SC1083,SC2002,\
SC2010,SC2012,SC2016,SC2034,SC2045,SC2046,SC2068,SC2086,SC2089,SC2090,\
SC2097,SC2098,SC2119,SC2120,SC2128,\
SC2129,SC2140,SC2142,SC2143,SC2154,SC2155"
SC2129,SC2140,SC2142,SC2143,SC2154"
	# 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.
+10 −5
Original line number Diff line number Diff line
@@ -30,9 +30,12 @@ function pci_can_use() {

# This function will ignore PCI PCI_WHITELIST and PCI_BLACKLIST
function iter_all_pci_class_code() {
	local class="$(printf %02x $((0x$1)))"
	local subclass="$(printf %02x $((0x$2)))"
	local progif="$(printf %02x $((0x$3)))"
	local class
	local subclass
	local progif
	class="$(printf %02x $((0x$1)))"
	subclass="$(printf %02x $((0x$2)))"
	progif="$(printf %02x $((0x$3)))"

	if hash lspci &>/dev/null; then
		if [ "$progif" != "00" ]; then
@@ -57,8 +60,10 @@ function iter_all_pci_class_code() {

# This function will ignore PCI PCI_WHITELIST and PCI_BLACKLIST
function iter_all_pci_dev_id() {
	local ven_id="$(printf %04x $((0x$1)))"
	local dev_id="$(printf %04x $((0x$2)))"
	local ven_id
	local dev_id
	ven_id="$(printf %04x $((0x$1)))"
	dev_id="$(printf %04x $((0x$2)))"

	if hash lspci &>/dev/null; then
		lspci -mm -n -D | awk -v ven="\"$ven_id\"" -v dev="\"${dev_id}\"" -F " " \
+6 −3
Original line number Diff line number Diff line
@@ -79,8 +79,10 @@ function check_for_driver {

function pci_dev_echo() {
	local bdf="$1"
	local vendor="$(cat /sys/bus/pci/devices/$bdf/vendor)"
	local device="$(cat /sys/bus/pci/devices/$bdf/device)"
	local vendor
	local device
	vendor="$(cat /sys/bus/pci/devices/$bdf/vendor)"
	device="$(cat /sys/bus/pci/devices/$bdf/device)"
	shift
	echo "$bdf (${vendor#0x} ${device#0x}): $*"
}
@@ -118,7 +120,8 @@ function linux_bind_driver() {

function linux_unbind_driver() {
	local bdf="$1"
	local ven_dev_id=$(lspci -n -s $bdf | cut -d' ' -f3 | sed 's/:/ /')
	local ven_dev_id
	ven_dev_id=$(lspci -n -s $bdf | cut -d' ' -f3 | sed 's/:/ /')
	local old_driver_name="no driver"

	if [ -e "/sys/bus/pci/devices/$bdf/driver" ]; then
+2 −1
Original line number Diff line number Diff line
@@ -13,7 +13,8 @@ function raid_unmap_data_verify() {
	if hash blkdiscard; then
		local nbd=$1
		local rpc_server=$2
		local blksize=$(lsblk -o  LOG-SEC $nbd | grep -v LOG-SEC | cut -d ' ' -f 5)
		local blksize
		blksize=$(lsblk -o  LOG-SEC $nbd | grep -v LOG-SEC | cut -d ' ' -f 5)
		local rw_blk_num=4096
		local rw_len=$((blksize * rw_blk_num))
		local unmap_blk_offs=(0   1028 321)
+18 −9
Original line number Diff line number Diff line
@@ -462,7 +462,8 @@ function killprocess() {
		if [ "$(ps --no-headers -o comm= $1)" = "sudo" ]; then
			# kill the child process, which is the actual app
			# (assume $1 has just one child)
			local child="$(pgrep -P $1)"
			local child
			child="$(pgrep -P $1)"
			echo "killing process with pid $child"
			kill $child
		else
@@ -559,7 +560,8 @@ function kill_stub() {

function run_test() {
	xtrace_disable
	local test_type="$(echo $1 | tr '[:lower:]' '[:upper:]')"
	local test_type
	test_type="$(echo $1 | tr '[:lower:]' '[:upper:]')"
	shift
	echo "************************************"
	echo "START TEST $test_type $*"
@@ -806,7 +808,8 @@ function fio_bdev()
	local bdev_plugin="$rootdir/examples/bdev/fio_plugin/fio_plugin"

	# Preload AddressSanitizer library to fio if fio_plugin was compiled with it
	local asan_lib=$(ldd $bdev_plugin | grep libasan | awk '{print $3}')
	local asan_lib
	asan_lib=$(ldd $bdev_plugin | grep libasan | awk '{print $3}')

	LD_PRELOAD="$asan_lib $bdev_plugin" "$fio_dir"/fio "$@"
}
@@ -826,9 +829,12 @@ function fio_nvme()
function get_lvs_free_mb()
{
	local lvs_uuid=$1
	local lvs_info=$($rpc_py bdev_lvol_get_lvstores)
	local fc=$(jq ".[] | select(.uuid==\"$lvs_uuid\") .free_clusters" <<< "$lvs_info")
	local cs=$(jq ".[] | select(.uuid==\"$lvs_uuid\") .cluster_size" <<< "$lvs_info")
	local lvs_info
	local fc
	local cs
	lvs_info=$($rpc_py bdev_lvol_get_lvstores)
	fc=$(jq ".[] | select(.uuid==\"$lvs_uuid\") .free_clusters" <<< "$lvs_info")
	cs=$(jq ".[] | select(.uuid==\"$lvs_uuid\") .cluster_size" <<< "$lvs_info")

	# Change to MB's
	free_mb=$((fc*cs/1024/1024))
@@ -838,9 +844,12 @@ function get_lvs_free_mb()
function get_bdev_size()
{
	local bdev_name=$1
	local bdev_info=$($rpc_py bdev_get_bdevs -b $bdev_name)
	local bs=$(jq ".[] .block_size" <<< "$bdev_info")
	local nb=$(jq ".[] .num_blocks" <<< "$bdev_info")
	local bdev_info
	local bs
	local nb
	bdev_info=$($rpc_py bdev_get_bdevs -b $bdev_name)
	bs=$(jq ".[] .block_size" <<< "$bdev_info")
	nb=$(jq ".[] .num_blocks" <<< "$bdev_info")

	# Change to MB's
	bdev_size=$((bs*nb/1024/1024))
Loading