mirror of
https://github.com/raspberrypi/rpi-eeprom.git
synced 2026-01-20 21:13:36 +08:00
Remove variable expansion in arithmetic
https://www.shellcheck.net/wiki/SC2004
This commit is contained in:
@@ -50,8 +50,8 @@ check_key_set() {
|
||||
}
|
||||
|
||||
read_key() {
|
||||
out=READ_KEY="$(vcmailbox 0x00030081 $((8 + $ROW_COUNT * 4)) $((8 + $ROW_COUNT * 4)) $ROW_OFFSET $ROW_COUNT 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)" || die "Failed to read the current key from OTP"
|
||||
READ_KEY="$(echo "${out}" | sed 's/0x//g' | awk -v last=$((8 + $ROW_COUNT)) '{for(i=8;i<last;i++) printf $i; print ""}')"
|
||||
out=READ_KEY="$(vcmailbox 0x00030081 $((8 + ROW_COUNT * 4)) $((8 + ROW_COUNT * 4)) $ROW_OFFSET $ROW_COUNT 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)" || die "Failed to read the current key from OTP"
|
||||
READ_KEY="$(echo "${out}" | sed 's/0x//g' | awk -v last=$((8 + ROW_COUNT)) '{for(i=8;i<last;i++) printf $i; print ""}')"
|
||||
}
|
||||
|
||||
write_key() {
|
||||
@@ -59,7 +59,7 @@ write_key() {
|
||||
# Normalize formatting and check the length
|
||||
key="$(echo "${key}" | tr 'A-Z' 'a-z')"
|
||||
key="$(echo "${key}" | sed 's/[^a-f0-9]//g')"
|
||||
[ "$(echo -n "${key}" | wc -c)" = $(($ROW_COUNT * 4 * 2)) ] || die "Invalid key parameter"
|
||||
[ "$(echo -n "${key}" | wc -c)" = $((ROW_COUNT * 4 * 2)) ] || die "Invalid key parameter"
|
||||
|
||||
count=0
|
||||
key_params=""
|
||||
@@ -83,7 +83,7 @@ write_key() {
|
||||
fi
|
||||
fi
|
||||
|
||||
vcmailbox 0x38081 $((8 + $ROW_COUNT * 4)) $((8 + $ROW_COUNT * 4)) $ROW_OFFSET $ROW_COUNT ${key_params} || die "Failed to write key"
|
||||
vcmailbox 0x38081 $((8 + ROW_COUNT * 4)) $((8 + ROW_COUNT * 4)) $ROW_OFFSET $ROW_COUNT ${key_params} || die "Failed to write key"
|
||||
read_key
|
||||
[ "${READ_KEY}" = "${key}" ] || die "Key readback check failed. ${out}"
|
||||
}
|
||||
@@ -151,7 +151,7 @@ fi
|
||||
if [ $ROW_OFFSET -lt 0 ]; then
|
||||
die "Offset too small"
|
||||
fi
|
||||
if [ ${ROW_OFFSET} -gt $(($MAX_ROW_COUNT - $ROW_COUNT)) ]; then
|
||||
if [ ${ROW_OFFSET} -gt $((MAX_ROW_COUNT - ROW_COUNT)) ]; then
|
||||
die "Offset too big"
|
||||
fi
|
||||
if [ -z $(which vcmailbox) ]; then
|
||||
|
||||
Reference in New Issue
Block a user