Re: [PATCH 5/6] generic/775: Fix an infinite loop due to variable name clash

Disha Goel <[email protected]>
Newsgroups org.kernel.vger.fstests
Message-ID <[email protected]>
On 10/04/26 12:06 pm, 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. Use local variable to fix this and while we are at it,
> rename it for clarity.
> 
> Reported-by: Disha Goel <[email protected]>
> Signed-off-by: Ojaswin Mujoo <[email protected]>

I've tested this patch and it fixes the infinite loop issue. The test 
now runs to completion without getting stuck in an infinite loop.

Tested-by: Disha Goel <[email protected]>

> ---
>   tests/generic/775 | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/generic/775 b/tests/generic/775
> index 2a4287bb..6dc005a0 100755
> --- a/tests/generic/775
> +++ b/tests/generic/775
> @@ -41,7 +41,8 @@ prep_mixed_mapping() {
>   
>   	local operations=("W" "H" "U")
>   	local num_blocks=$((awu_max / blksz))
> -	for ((i=0; i<num_blocks; i++)); do
> +	local blkno
> +	for ((blkno=0; blkno<num_blocks; blkno++)); do
>   		local index=$((RANDOM % ${#operations[@]}))
>   		local map="${operations[$index]}"
>   		local mapping="${mapping}${map}"

-- 
Regards,
Disha
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.