From: Bart Van Assche <bvanassche@acm.org>
To: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Cc: linux-block@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>
Subject: [PATCH blktests v2 1/2] nbd/rc: Declare the loop variables of the wait helpers local
Date: Fri, 20 Nov 2026 13:34:33 -0800 [thread overview]
Message-ID: <20261120213434.2945873-2-bvanassche@acm.org> (raw)
In-Reply-To: <20261120213434.2945873-1-bvanassche@acm.org>
_wait_for_nbd_connect() and _wait_for_nbd_disconnect() use the variable
"i" without declaring it local. Since bash uses dynamic scoping, these
functions modify the variable "i" of their caller, or the global variable
"i" if the caller did not declare one. Declare "i" and "sz" local to
prevent this.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
tests/nbd/rc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/nbd/rc b/tests/nbd/rc
index 6205c4938b7c..9a68c2c9abd4 100644
--- a/tests/nbd/rc
+++ b/tests/nbd/rc
@@ -42,6 +42,8 @@ _have_nbd_netlink() {
}
_wait_for_nbd_connect() {
+ local i sz
+
for ((i = 0; i < 3; i++)); do
sz=$(lsblk --raw --noheadings -o SIZE /dev/nbd0)
if [ "$sz" != "0B" ]; then
@@ -53,6 +55,8 @@ _wait_for_nbd_connect() {
}
_wait_for_nbd_disconnect() {
+ local i
+
for ((i = 0; i < 3; i++)); do
if [[ ! -e /sys/kernel/debug/nbd/nbd0/tasks ]]; then
return 0
next prev parent reply other threads:[~2026-11-20 21:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 21:34 [PATCH blktests v2 0/2] Add an NBD performance test Bart Van Assche
2026-11-20 21:34 ` Bart Van Assche [this message]
2026-11-20 21:34 ` [PATCH blktests v2 2/2] nbd/006: Measure NBD IOPS with a null_blk backing device Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120213434.2945873-2-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=linux-block@vger.kernel.org \
--cc=shinichiro.kawasaki@wdc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox