From dbcc917d8167a6222c374fdfbbb6ab13f1b25ca7 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 9 Mar 2018 15:58:27 -0700 Subject: [PATCH] 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 Reviewed-on: https://review.gerrithub.io/403370 Tested-by: SPDK Automated Test System Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris --- scripts/setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index fa047e034b..39aa13a555 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -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