All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: Li Zhijian <lizhijian@fujitsu.com>
Cc: nvdimm@lists.linux.dev, 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: Tue, 12 Dec 2023 12:51:34 -0800	[thread overview]
Message-ID: <ZXjH1o1rq/Un/X0w@aschofie-mobl2> (raw)
In-Reply-To: <20231212074228.1261164-1-lizhijian@fujitsu.com>

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.

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
> 
> 

  parent reply	other threads:[~2023-12-12 20:51 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 ` Alison Schofield [this message]
2023-12-13  8:02   ` [ndctl PATCH v2 1/2] test/cxl-region-sysfs.sh: use '[[ ]]' command to evaluate operands as arithmetic expressions Zhijian Li (Fujitsu)

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=ZXjH1o1rq/Un/X0w@aschofie-mobl2 \
    --to=alison.schofield@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=lizhijian@fujitsu.com \
    --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 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.