From: "Zhijian Li (Fujitsu)" <lizhijian@fujitsu.com>
To: Alison Schofield <alison.schofield@intel.com>
Cc: "nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>,
"linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>
Subject: Re: [ndctl PATCH v2 1/2] test/cxl-region-sysfs.sh: use '[[ ]]' command to evaluate operands as arithmetic expressions
Date: Wed, 13 Dec 2023 08:02:37 +0000 [thread overview]
Message-ID: <dc7e023d-6e93-44f9-a9c2-c24dc5eabab6@fujitsu.com> (raw)
In-Reply-To: <ZXjH1o1rq/Un/X0w@aschofie-mobl2>
On 13/12/2023 04:51, Alison Schofield wrote:
> On Tue, Dec 12, 2023 at 03:42:27PM +0800, Li Zhijian wrote:
>> It doesn't work for '[ operand1 -ne operand2 ]' where either operand1 or
>> operand2 is not integer value.
>> It's tested that bash 4.1/4.2/5.0/5.1 are impacted.
>
> So, when validating the endpoint decoder settings the region_size and
> region_base were not really being checked. With this syntax fix, the
> check works as intended.
>
> Please include such an impact statement.
No problem, thanks
>
> Alison
>
>>
>> Per bash man page, use '[[ ]]' command to evaluate operands as arithmetic
>> expressions
>>
>> Fix errors:
>> line 111: [: 0x80000000: integer expression expected
>> line 112: [: 0x3ff110000000: integer expression expected
>> line 141: [: 0x80000000: integer expression expected
>> line 143: [: 0x3ff110000000: integer expression expected
>>
>> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
>> ---
>> V2: use '[[ ]]' instead of conversion before comparing in V1
>> ---
>> test/cxl-region-sysfs.sh | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/test/cxl-region-sysfs.sh b/test/cxl-region-sysfs.sh
>> index 8636392..6a5da6d 100644
>> --- a/test/cxl-region-sysfs.sh
>> +++ b/test/cxl-region-sysfs.sh
>> @@ -108,8 +108,8 @@ do
>>
>> sz=$(cat /sys/bus/cxl/devices/$i/size)
>> res=$(cat /sys/bus/cxl/devices/$i/start)
>> - [ $sz -ne $region_size ] && err "$LINENO: decoder: $i sz: $sz region_size: $region_size"
>> - [ $res -ne $region_base ] && err "$LINENO: decoder: $i base: $res region_base: $region_base"
>> + [[ $sz -ne $region_size ]] && err "$LINENO: decoder: $i sz: $sz region_size: $region_size"
>> + [[ $res -ne $region_base ]] && err "$LINENO: decoder: $i base: $res region_base: $region_base"
>> done
>>
>> # validate all switch decoders have the correct settings
>> @@ -138,9 +138,9 @@ do
>>
>> res=$(echo $decoder | jq -r ".resource")
>> sz=$(echo $decoder | jq -r ".size")
>> - [ $sz -ne $region_size ] && err \
>> + [[ $sz -ne $region_size ]] && err \
>> "$LINENO: decoder: $i sz: $sz region_size: $region_size"
>> - [ $res -ne $region_base ] && err \
>> + [[ $res -ne $region_base ]] && err \
>> "$LINENO: decoder: $i base: $res region_base: $region_base"
>> done
>>
>> --
>> 2.41.0
>>
>>
prev parent reply other threads:[~2023-12-13 8:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 7:42 [ndctl PATCH v2 1/2] test/cxl-region-sysfs.sh: use '[[ ]]' command to evaluate operands as arithmetic expressions Li Zhijian
2023-12-12 7:42 ` [ndctl PATCH v2 2/2] test/cxl-region-sysfs.sh: Fix cxl-region-sysfs.sh: line 107: [: missing `]' Li Zhijian
2023-12-12 20:54 ` Alison Schofield
2023-12-13 8:00 ` Zhijian Li (Fujitsu)
2023-12-12 22:46 ` Dan Williams
2023-12-13 7:50 ` Zhijian Li (Fujitsu)
2023-12-12 20:51 ` [ndctl PATCH v2 1/2] test/cxl-region-sysfs.sh: use '[[ ]]' command to evaluate operands as arithmetic expressions Alison Schofield
2023-12-13 8:02 ` Zhijian Li (Fujitsu) [this message]
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=dc7e023d-6e93-44f9-a9c2-c24dc5eabab6@fujitsu.com \
--to=lizhijian@fujitsu.com \
--cc=alison.schofield@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).