@@ -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
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. 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> --- V3: update changelog per Alison comments. V2: use '[[ ]]' instead of conversion before comparing in V1 --- test/cxl-region-sysfs.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)