Commit dbcc917d authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Jim Harris
Browse files

scripts/setup.sh: avoid clobbering $bdf variable



The get_nvme_name_from_bdf function uses the variable name $bdf, which
is also used as a loop iterator in its caller; since variables are
global by default in bash, this overwrites the original $bdf and may
cause unexpected behavior like skipping setup of some NVMe devices.

The long-term fix should be to declare all variables local in all
functions, but a minimal, targeted fix is to just rename the variable in
the inner function.

Change-Id: I53a877606a585415e8af525c6162ed7b0f67ba45
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/403370


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent a137b9af
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -139,8 +139,8 @@ function get_nvme_name_from_bdf {
		if [ -z "$link_name" ]; then
			link_name=$(readlink /sys/block/$dev/device)
		fi
		bdf=$(basename "$link_name")
		if [ "$bdf" = "$1" ]; then
		link_bdf=$(basename "$link_name")
		if [ "$link_bdf" = "$1" ]; then
			eval "$2=$dev"
			return
		fi