All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: fstests@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH] common/rc: Fix check for SCRATCH_DEV_POOL presence in _scratch_dev_pool_get
Date: Mon,  1 Nov 2021 15:56:58 +0200	[thread overview]
Message-ID: <20211101135658.385131-1-nborisov@suse.com> (raw)
In-Reply-To: <20211101133511.383232-1-nborisov@suse.com>

Current check is buggy because it can never trigger as even if
SCRATCH_DEV_POOL is not defined config_ndevs will get a value of 0 from
'wc -w', this in turn makes 'typeset -p config_ndevs' always return 0,
triggering the existing check a noop.

Fix this by explicitly checking for the presence of SCHRATC_DEV_POOL

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---

Eryu,

Please use this patch as it's a more proper fix

 common/rc | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/common/rc b/common/rc
index 7f693d3922e8..07b69880eea6 100644
--- a/common/rc
+++ b/common/rc
@@ -917,15 +917,15 @@ _scratch_dev_pool_get()
 		_fail "Usage: _scratch_dev_pool_get ndevs"
 	fi

-	local test_ndevs=$1
-	local config_ndevs=`echo $SCRATCH_DEV_POOL| wc -w`
-	local -a devs="( $SCRATCH_DEV_POOL )"
-
-	typeset -p config_ndevs >/dev/null 2>&1
+	typeset -p SCRATCH_DEV_POOL >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		_fail "Bug: cant find SCRATCH_DEV_POOL ndevs"
 	fi

+	local test_ndevs=$1
+	local config_ndevs=`echo $SCRATCH_DEV_POOL| wc -w`
+	local -a devs="( $SCRATCH_DEV_POOL )"
+
 	if [ $config_ndevs -lt $test_ndevs ]; then
 		_notrun "Need at least test requested number of ndevs $test_ndevs"
 	fi
--
2.17.1


  reply	other threads:[~2021-11-01 13:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 13:35 [PATCH] common/rc: Remove impossible check Nikolay Borisov
2021-11-01 13:56 ` Nikolay Borisov [this message]
2021-11-01 14:26   ` [PATCH] common/rc: Fix check for SCRATCH_DEV_POOL presence in _scratch_dev_pool_get Zorro Lang
2021-11-01 14:15     ` Nikolay Borisov
2021-11-01 14:42       ` Zorro Lang

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=20211101135658.385131-1-nborisov@suse.com \
    --to=nborisov@suse.com \
    --cc=fstests@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.