NVDIMM Device and Persistent Memory development
 help / color / mirror / Atom feed
From: "Zhijian Li (Fujitsu)" <lizhijian@fujitsu.com>
To: Dan Williams <dan.j.williams@intel.com>,
	"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>
Cc: "linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>
Subject: Re: [ndctl PATCH 2/3] test/cxl-region-sysfs.sh: use operator '!=' to compare hexadecimal value
Date: Thu, 7 Dec 2023 09:00:23 +0000	[thread overview]
Message-ID: <8c94d1b6-1dd6-465b-906d-4f65cd992619@fujitsu.com> (raw)
In-Reply-To: <6570e93b1dd74_45e0129427@dwillia2-xfh.jf.intel.com.notmuch>



On 07/12/2023 05:35, Dan Williams wrote:
> Li Zhijian wrote:
>> 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
> 
> Similar commentary on how found and how someone knows that they need
> this patch, and maybe a note about which version of bash is upset about
> this given this problem has been present for a long time without issue.

I think it impacted all version of BASH (tested on bash 4.1, 4.2, 5.0, 5.1)


> 
>>
>> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
>> ---
>>   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 ded7aa1..89f21a3 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" != "$region_size" ] && err "$LINENO: decoder: $i sz: $sz region_size: $region_size"
>> +	[ "$res" != "$region_base" ] && err "$LINENO: decoder: $i base: $res region_base: $region_base"
> 
> maybe use ((sz != region_size)) to make it explicit that this is an
> arithmetic comparison? I would defer to Vishal's preference here.

Per bash man page, we can also use [[ ]] instead of [ ], so that we are able to get rid of patch1

        arg1 OP arg2
               OP is one of -eq, -ne, -lt, -le, -gt, or -ge.  These arithmetic binary operators return true if arg1 is equal to, not equal to, less than, less than or equal to, greater than, or greater than or equal  to  arg2,
               respectively.  Arg1 and arg2 may be positive or negative integers.  When used with the [[ command, Arg1 and Arg2 are evaluated as arithmetic expressions  (see ARITHMETIC EVALUATION above).


  reply	other threads:[~2023-12-07  9:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-23  2:30 [ndctl PATCH 1/3] test/cxl-region-sysfs.sh: covert size and resource to hex before test Li Zhijian
2023-11-23  2:30 ` [ndctl PATCH 2/3] test/cxl-region-sysfs.sh: use operator '!=' to compare hexadecimal value Li Zhijian
2023-12-06 21:35   ` Dan Williams
2023-12-07  9:00     ` Zhijian Li (Fujitsu) [this message]
2023-11-23  2:30 ` [ndctl PATCH 3/3] test/cxl-region-sysfs.sh: Fix cxl-region-sysfs.sh: line 107: [: missing `]' Li Zhijian
2023-12-06 21:37   ` Dan Williams
2023-12-07  9:07     ` Zhijian Li (Fujitsu)
2023-12-06 21:31 ` [ndctl PATCH 1/3] test/cxl-region-sysfs.sh: covert size and resource to hex before test Dan Williams

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=8c94d1b6-1dd6-465b-906d-4f65cd992619@fujitsu.com \
    --to=lizhijian@fujitsu.com \
    --cc=dan.j.williams@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).