Skip to content

Commit 43c159b

Browse files
committed
Dasharo-deploy: Pass arrays instead of namerefs
Use arrays instead of namerefs in helper functions related to dasharo-deploy. The reason is this is easier to read. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@3mdeb.com>
1 parent e2bf4cc commit 43c159b

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

include/dts-functions.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -706,12 +706,12 @@ is_region_locked() {
706706
# 0 if found, 1 otherwise.
707707
flashrom_check_for_region() {
708708
local region="$1"
709-
local -n _args="$2"
710-
local i
709+
shift
710+
local -a args=("$@")
711711

712712
# Iterate only up to length-1 since we inspect pairs (i, i+1)
713-
for ((i = 0; i < ${#_args[@]} - 1; i++)); do
714-
if [[ "${_args[i]}" == "-i" && "${_args[i + 1]}" == "$region" ]]; then
713+
for ((i = 0; i < ${#args[@]} - 1; i++)); do
714+
if [[ "${args[i]}" == "-i" && "${args[i + 1]}" == "$region" ]]; then
715715
return 0
716716
fi
717717
done
@@ -722,20 +722,20 @@ flashrom_check_for_region() {
722722
# Does a final check for all flashrom parameters if FD or ME are to be flashed
723723
# and if they're locked. Decide whether we can proceed if any regions are locked.
724724
flashrom_region_check() {
725-
local -n args="$1"
725+
local -a args=("$@")
726726
local locked_regions=()
727727
local region_list verb
728728

729729
# If switching to heads, always check the region, otherwise check region only
730730
# if specified in params.
731731
# The reason is we want to handle both "overwrites" form metadata as well as
732732
# dynamically added params from set_intel_regions_update_params()
733-
if (flashrom_check_for_region fd args || [[ "$SWITCHING_TO" == "heads" ]]) &&
733+
if (flashrom_check_for_region fd "${args[@]}" || [[ "$SWITCHING_TO" == "heads" ]]) &&
734734
is_region_locked fd; then
735735
locked_regions+=("FD")
736736
fi
737737

738-
if (flashrom_check_for_region me args || [[ "$SWITCHING_TO" == "heads" ]]) &&
738+
if (flashrom_check_for_region me "${args[@]}" || [[ "$SWITCHING_TO" == "heads" ]]) &&
739739
is_region_locked me; then
740740
locked_regions+=("ME")
741741
fi

scripts/dasharo-deploy.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ deploy_firmware() {
10181018
# shellcheck disable=SC2178
10191019
local -n args_ref="_job_args_$i"
10201020

1021-
if flashrom_check_for_region fd args_ref; then
1021+
if flashrom_check_for_region fd "${args_ref[@]}"; then
10221022
echo "Scheduling dedicated FD update..."
10231023
schedule_job "Failed to flash FD" \
10241024
-p "$PROGRAMMER_BIOS" \
@@ -1047,7 +1047,7 @@ deploy_firmware() {
10471047
done
10481048

10491049
# Last resort check before flashing
1050-
if ! flashrom_region_check _all_flashrom_args; then
1050+
if ! flashrom_region_check "${_all_flashrom_args[@]}"; then
10511051
return 1
10521052
fi
10531053

0 commit comments

Comments
 (0)