From: "Darrick J. Wong" <djwong@kernel.org>
To: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Cc: Zorro Lang <zlang@redhat.com>,
fstests@vger.kernel.org, Disha Goel <disgoel@linux.ibm.com>
Subject: Re: [PATCH 4/4] generic/775: Fix an infinite loop due to variable name clash
Date: Mon, 6 Apr 2026 08:39:08 -0700 [thread overview]
Message-ID: <20260406153908.GM6212@frogsfrogsfrogs> (raw)
In-Reply-To: <adJsjDpAxYGhyyrO@li-dc0c254c-257c-11b2-a85c-98b6c1322444.ibm.com>
On Sun, Apr 05, 2026 at 07:37:08PM +0530, Ojaswin Mujoo wrote:
> On Wed, Apr 01, 2026 at 07:32:18AM -0700, Darrick J. Wong wrote:
> > On Wed, Apr 01, 2026 at 04:10:50PM +0530, Ojaswin Mujoo wrote:
> > > We use i as the iteration variable in the main test loop as well as some
> > > internal loops. Due to this clash, $i variable of main test loops was
> > > getting modified by the following loop in prep_mixed_mapping().
> > >
> > > for ((i=0; i<num_blocks; i++)); do
> > >
> > > If num_blocks is less than 10 (example ext4 with blocksize 4k and
> > > cluster size 8k) i would always be set as 3 and the main loop would
> > > never exit. Take the simplest approach of just renaming the variable.
> > >
> > > Reported-by: Disha Goel <disgoel@linux.ibm.com>
> > > Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
> > > ---
> > > tests/generic/775 | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/tests/generic/775 b/tests/generic/775
> > > index 2a4287bb..19ae95e2 100755
> > > --- a/tests/generic/775
> > > +++ b/tests/generic/775
> > > @@ -41,7 +41,7 @@ prep_mixed_mapping() {
> > >
> > > local operations=("W" "H" "U")
> > > local num_blocks=$((awu_max / blksz))
> > > - for ((i=0; i<num_blocks; i++)); do
> > > + for ((j=0; j<num_blocks; j++)); do
> >
> > You're right that the single-letter variables are a really bad idea in
> > languages like bash/python/etc where functions can see variables in
> > caller's scope if they're not explicitly marked local.
> >
> > But a) why not use "local i" to prevent that; and (b) if you're going
> > to rename it, why not "blkno"?
>
> Hey Darrick thanks for the review.
>
> Why not both a) and b) :).
> I probably shouldve done that in the first place. I'll fix in v2
Yeah, that works! :)
Thanks for making those fixes.
--D
> Thanks,
> ojaswin
>
> >
> > --D
> >
> > > local index=$((RANDOM % ${#operations[@]}))
> > > local map="${operations[$index]}"
> > > local mapping="${mapping}${map}"
> > > --
> > > 2.53.0
> > >
> > >
>
next prev parent reply other threads:[~2026-04-06 15:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 10:40 [PATCH 1/4] ext4/061,062: Minor fixes and refactoring Ojaswin Mujoo
2026-04-01 10:40 ` [PATCH 2/4] generic/765: Fix sysfs path for nvme partitions Ojaswin Mujoo
2026-04-01 14:08 ` Darrick J. Wong
2026-04-05 15:07 ` Ojaswin Mujoo
2026-04-06 15:43 ` Darrick J. Wong
2026-04-07 14:48 ` Ojaswin Mujoo
2026-04-01 10:40 ` [PATCH 3/4] generic/765: Ignore mkfs warning Ojaswin Mujoo
2026-04-01 14:30 ` Darrick J. Wong
2026-04-05 14:10 ` Ojaswin Mujoo
2026-04-01 10:40 ` [PATCH 4/4] generic/775: Fix an infinite loop due to variable name clash Ojaswin Mujoo
2026-04-01 14:32 ` Darrick J. Wong
2026-04-05 14:07 ` Ojaswin Mujoo
2026-04-06 15:39 ` Darrick J. Wong [this message]
2026-04-01 14:33 ` [PATCH 1/4] ext4/061,062: Minor fixes and refactoring Darrick J. Wong
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=20260406153908.GM6212@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=disgoel@linux.ibm.com \
--cc=fstests@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=zlang@redhat.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