Skip to content

Commit 19f347b

Browse files
bvanasscheosandov
authored andcommitted
Fix multiple shellcheck warnings
The latest version of shellcheck reports the following warnings: check:307:9: warning: Quote arguments to unset so they're not glob expanded. [SC2184] check:505:10: warning: Quote arguments to unset so they're not glob expanded. [SC2184] check:506:10: warning: Quote arguments to unset so they're not glob expanded. [SC2184] check:539:11: warning: Quote arguments to unset so they're not glob expanded. [SC2184] new:102:19: note: Expansions inside ${..} need to be quoted separately, otherwise they match as patterns. [SC2295] common/rc:272:37: warning: -ne treats this as an arithmetic expression. Use != to compare as string (or expand explicitly with $((expr))). [SC2309] tests/block/008:65:10: warning: Quote arguments to unset so they're not glob expanded. [SC2184] tests/block/008:71:10: warning: Quote arguments to unset so they're not glob expanded. [SC2184] This patch fixes the above warnings. Signed-off-by: Bart Van Assche <[email protected]>
1 parent 38fc272 commit 19f347b

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

check

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ _cleanup() {
304304
for key in "${!TEST_DEV_QUEUE_SAVED[@]}"; do
305305
value="${TEST_DEV_QUEUE_SAVED["$key"]}"
306306
echo "$value" >"${TEST_DEV_SYSFS}/queue/${key}"
307-
unset TEST_DEV_QUEUE_SAVED["$key"]
307+
unset "TEST_DEV_QUEUE_SAVED[$key]"
308308
done
309309

310310
if [[ "${RESTORE_CPUS_ONLINE:-}" ]]; then
@@ -502,8 +502,8 @@ _run_test() {
502502

503503
if (( FALLBACK_DEVICE )); then
504504
cleanup_fallback_device
505-
unset TEST_DEV_SYSFS_DIRS["${TEST_DEVS[0]}"]
506-
unset TEST_DEV_PART_SYSFS_DIRS["${TEST_DEVS[0]}"]
505+
unset "TEST_DEV_SYSFS_DIRS[${TEST_DEVS[0]}]"
506+
unset "TEST_DEV_PART_SYSFS_DIRS[${TEST_DEVS[0]}]"
507507
TEST_DEVS=()
508508
fi
509509

@@ -536,7 +536,7 @@ _run_group() {
536536
group_device_requires
537537
if [[ -v SKIP_REASON ]]; then
538538
_output_notrun "${group}/*** => $(basename "$TEST_DEV")"
539-
unset TEST_DEVS["$i"]
539+
unset "TEST_DEVS[$i]"
540540
unset SKIP_REASON
541541
fi
542542
done

common/rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ _require_test_dev_in_hotplug_slot() {
269269

270270
local slt_cap
271271
slt_cap="$(setpci -s "${parent}" CAP_EXP+14.w)"
272-
if [[ $((0x${slt_cap} & 0x60)) -ne 0x60 ]]; then
272+
if [[ $((0x${slt_cap} & 0x60)) -ne $((0x60)) ]]; then
273273
SKIP_REASON="$TEST_DEV is not in a hot pluggable slot"
274274
return 1
275275
fi

new

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ fi
9999
for test in tests/"$group"/+([0-9]); do
100100
:
101101
done
102-
seq=${test##tests/$group/+(0)}
102+
seq=${test##tests/"${group}"/+(0)}
103103
test_name="${group}/$(printf "%03d" $((seq + 1)))"
104104

105105
cat << EOF > "tests/${test_name}"

tests/block/008

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ test_device() {
6262
idx=$((RANDOM % ${#online_cpus[@]}))
6363
_offline_cpu "${online_cpus[$idx]}"
6464
offline_cpus+=("${online_cpus[$idx]}")
65-
unset online_cpus["$idx"]
65+
unset "online_cpus[$idx]"
6666
online_cpus=("${online_cpus[@]}")
6767
else
6868
idx=$((RANDOM % ${#offline_cpus[@]}))
6969
_online_cpu "${offline_cpus[$idx]}"
7070
online_cpus+=("${offline_cpus[$idx]}")
71-
unset offline_cpus["$idx"]
71+
unset "offline_cpus[$idx]"
7272
offline_cpus=("${offline_cpus[@]}")
7373
fi
7474
end_time=$(date +%s)

0 commit comments

Comments
 (0)