From a40f083a67098d4c19a1a46e4fd2a92b4752dd3b Mon Sep 17 00:00:00 2001 From: Namyoon Woo Date: Wed, 15 May 2019 13:50:50 -0700 Subject: flash_ec: prevent null entry in dut-control recovery list With some faulty platforms, dut-control might fail and dut-control recovery list might have a null entry. On flash_ec exit, the command run "dut-control ''" displays a long error message, which confuses users. This CL prevents that happening. BUG=None BRANCH=None TEST=manually ran on hatch, scarlet and coral Change-Id: I26b8c46b5ce6ff529cd368adeb6b24a01ed14566 Signed-off-by: Namyoon Woo Reviewed-on: https://chromium-review.googlesource.com/1614360 Reviewed-by: Matthew Blecker --- util/flash_ec | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/util/flash_ec b/util/flash_ec index e55db51fd1..7bb5a463f4 100755 --- a/util/flash_ec +++ b/util/flash_ec @@ -622,8 +622,12 @@ declare -a save # $2: (optional) Value to restore for the name at exit. ####################################### function servo_save_add() { + local CTRL_RESULT= case $# in - 1) save+=( "$( "${DUT_CONTROL_CMD[@]}" "$@" )" ) + 1) CTRL_RESULT="$( "${DUT_CONTROL_CMD[@]}" "$@" )" + if [[ -n "${CTRL_RESULT}" ]]; then + save+=( "${CTRL_RESULT}" ) + fi ;; 2) save+=( "$1:$2" ) ;; @@ -650,7 +654,9 @@ function servo_save() { function servo_restore() { info "Restoring servo settings..." for ctrl in "${save[@]}"; do - dut_control "$ctrl" + if [[ -n "${ctrl}" ]]; then + dut_control "${ctrl}" + fi done } -- cgit v1.2.1