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: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/403370
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Daniel Verkamp 2018-03-09 15:58:27 -07:00 committed by Jim Harris
parent a137b9afd0
commit dbcc917d81

View File

@ -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