[shellcheck] fix SC2155 warning (#8490)

Declare and assign separately to avoid masking return values.
This commit is contained in:
Jonathan Hui
2022-12-07 16:23:20 -08:00
parent 864236cbf1
commit 48c0582e4e
13 changed files with 125 additions and 52 deletions
+5 -2
View File
@@ -29,8 +29,11 @@
set -euo pipefail
readonly OT_SHA_OLD="$(git cat-file -p HEAD | grep 'parent ' | head -n1 | cut -d' ' -f2)"
readonly OT_VERSIONS_FILE=tmp/api_versions
OT_SHA_OLD="$(git cat-file -p HEAD | grep 'parent ' | head -n1 | cut -d' ' -f2)"
readonly OT_SHA_OLD
OT_VERSIONS_FILE=tmp/api_versions
readonly OT_VERSIONS_FILE
die()
{
+5 -2
View File
@@ -29,8 +29,11 @@
set -euxo pipefail
readonly OT_TMP_DIR=/tmp/ot-arm-build-cmake
readonly OT_SHA_NEW=${GITHUB_SHA:-$(git rev-parse HEAD)}
OT_TMP_DIR=/tmp/ot-arm-build-cmake
readonly OT_TMP_DIR
OT_SHA_NEW=${GITHUB_SHA:-$(git rev-parse HEAD)}
readonly OT_SHA_NEW
build_nrf52840()
{
+2 -1
View File
@@ -29,7 +29,8 @@
set -euxo pipefail
readonly OT_BUILDDIR="$(pwd)/build"
OT_BUILDDIR="$(pwd)/build"
readonly OT_BUILDDIR
reset_source()
{
+6 -3
View File
@@ -112,7 +112,8 @@ do_check()
$RADIO_NCP_PATH 1 >"$RADIO_PTY" <"$RADIO_PTY" &
# Cover setting a valid network interface name.
readonly VALID_NETIF_NAME="wan$(date +%H%M%S)"
VALID_NETIF_NAME="wan$(date +%H%M%S)"
readonly VALID_NETIF_NAME
RADIO_URL="spinel+hdlc+uart://${CORE_PTY}?region=US&max-power-table=11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26"
@@ -140,7 +141,8 @@ do_check()
# sleep a while for daemon ready
sleep 2
readonly OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH=640
OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH=640
readonly OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH
local -r kMaxStringLength="$((OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH - 1))"
# verify success if command length doesn't exceed the limit
@@ -160,7 +162,8 @@ do_check()
# Cover setting a too long(max is 15 characters) network interface name.
# Expect exit code to be 2(OT_EXIT_INVALID_ARGUMENTS).
readonly INVALID_NETIF_NAME="wan0123456789123"
INVALID_NETIF_NAME="wan0123456789123"
readonly INVALID_NETIF_NAME
sudo "${OT_CLI}" -I "${INVALID_NETIF_NAME}" -n "${RADIO_URL}" || test $? = 2
OT_CLI_CMD="$PWD/build/posix/src/posix/ot-cli ${RADIO_URL}"
+6 -3
View File
@@ -29,9 +29,10 @@
set -euxo pipefail
readonly OT_SRCDIR="$(pwd)"
OT_SRCDIR="$(pwd)"
readonly OT_SRCDIR
readonly OT_BUILD_OPTIONS=(
OT_BUILD_OPTIONS=(
"-DOT_ANYCAST_LOCATOR=ON"
"-DOT_BUILD_EXECUTABLES=OFF"
"-DOT_BORDER_AGENT=ON"
@@ -75,13 +76,15 @@ readonly OT_BUILD_OPTIONS=(
"-DOT_SRP_CLIENT=ON"
"-DOT_SRP_SERVER=ON"
)
readonly OT_BUILD_OPTIONS
readonly OT_CFLAGS=(
OT_CFLAGS=(
"-DMBEDTLS_DEBUG_C"
"-I$(pwd)/third_party/mbedtls"
"-I$(pwd)/third_party/mbedtls/repo/include"
'-DMBEDTLS_CONFIG_FILE=\"mbedtls-config.h\"'
)
readonly OT_CFLAGS
main()
{
+2 -1
View File
@@ -29,7 +29,8 @@
set -euxo pipefail
readonly OT_BUILD_JOBS=$(getconf _NPROCESSORS_ONLN)
OT_BUILD_JOBS=$(getconf _NPROCESSORS_ONLN)
readonly OT_BUILD_JOBS
reset_source()
{
+2 -1
View File
@@ -29,7 +29,8 @@
set -euxo pipefail
readonly OT_BUILDDIR="$(pwd)/build"
OT_BUILDDIR="$(pwd)/build"
readonly OT_BUILDDIR
reset_source()
{
+11 -4
View File
@@ -29,10 +29,17 @@
set -euo pipefail
readonly OT_TMP_DIR=/tmp/ot-size-report
readonly OT_SHA_NEW=${GITHUB_SHA:-$(git rev-parse HEAD)}
readonly OT_SHA_OLD="$(git cat-file -p "${OT_SHA_NEW}" | grep 'parent ' | head -n1 | cut -d' ' -f2)"
readonly OT_REPORT_FILE=/tmp/size_report
OT_TMP_DIR=/tmp/ot-size-report
readonly OT_TMP_DIR
OT_SHA_NEW=${GITHUB_SHA:-$(git rev-parse HEAD)}
readonly OT_SHA_NEW
OT_SHA_OLD="$(git cat-file -p "${OT_SHA_NEW}" | grep 'parent ' | head -n1 | cut -d' ' -f2)"
readonly OT_SHA_OLD
OT_REPORT_FILE=/tmp/size_report
readonly OT_REPORT_FILE
setup_arm_gcc_7()
{
+6 -3
View File
@@ -65,10 +65,12 @@ set -euxo pipefail
OT_CMAKE_NINJA_TARGET=${OT_CMAKE_NINJA_TARGET:-}
OT_SRCDIR="$(cd "$(dirname "$0")"/.. && pwd)"
readonly OT_SRCDIR
readonly OT_PLATFORMS=(simulation posix)
readonly OT_POSIX_SIM_COMMON_OPTIONS=(
OT_PLATFORMS=(simulation posix)
readonly OT_PLATFORMS
OT_POSIX_SIM_COMMON_OPTIONS=(
"-DOT_ANYCAST_LOCATOR=ON"
"-DOT_BORDER_AGENT=ON"
"-DOT_BORDER_ROUTER=ON"
@@ -106,6 +108,7 @@ readonly OT_POSIX_SIM_COMMON_OPTIONS=(
"-DOT_RCP_RESTORATION_MAX_COUNT=2"
"-DOT_UPTIME=ON"
)
readonly OT_POSIX_SIM_COMMON_OPTIONS
die()
{
+5 -2
View File
@@ -29,8 +29,11 @@
set -euxo pipefail
readonly OT_MERGED_PROFILES=merged_profiles
readonly OT_GCOV_PREFIX_BASE=ot-run
OT_MERGED_PROFILES=merged_profiles
readonly OT_MERGED_PROFILES
OT_GCOV_PREFIX_BASE=ot-run
readonly OT_GCOV_PREFIX_BASE
merge_profiles()
{
+20 -10
View File
@@ -64,15 +64,25 @@
set -euo pipefail
readonly OT_BUILD_JOBS=$(getconf _NPROCESSORS_ONLN)
readonly OT_EXCLUDE_DIRS=(third_party doc/site)
OT_BUILD_JOBS=$(getconf _NPROCESSORS_ONLN)
readonly OT_BUILD_JOBS
readonly OT_CLANG_SOURCES=('*.c' '*.cc' '*.cpp' '*.h' '*.hpp')
readonly OT_MARKDOWN_SOURCES=('*.md')
readonly OT_PYTHON_SOURCES=('*.py')
OT_EXCLUDE_DIRS=(third_party doc/site)
readonly OT_EXCLUDE_DIRS
readonly OT_CLANG_TIDY_FIX_DIRS=('examples' 'include' 'src' 'tests')
readonly OT_CLANG_TIDY_BUILD_OPTS=(
OT_CLANG_SOURCES=('*.c' '*.cc' '*.cpp' '*.h' '*.hpp')
readonly OT_CLANG_SOURCES
OT_MARKDOWN_SOURCES=('*.md')
readonly OT_MARKDOWN_SOURCES
OT_PYTHON_SOURCES=('*.py')
readonly OT_PYTHON_SOURCES
OT_CLANG_TIDY_FIX_DIRS=('examples' 'include' 'src' 'tests')
readonly OT_CLANG_TIDY_FIX_DIRS
OT_CLANG_TIDY_BUILD_OPTS=(
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON'
'-DOT_ANYCAST_LOCATOR=ON'
'-DOT_APP_RCP=OFF'
@@ -129,8 +139,9 @@ readonly OT_CLANG_TIDY_BUILD_OPTS=(
'-DOT_COMPILE_WARNING_AS_ERROR=ON'
'-DOT_UPTIME=ON'
)
readonly OT_CLANG_TIDY_BUILD_OPTS
readonly OT_CLANG_TIDY_CHECKS="\
OT_CLANG_TIDY_CHECKS="\
-*,\
google-explicit-constructor,\
google-readability-casting,\
@@ -149,8 +160,7 @@ readability-redundant-member-init,\
readability-simplify-boolean-expr,\
readability-static-accessed-through-instance,\
"
#performance-for-range-copy\
readonly OT_CLANG_TIDY_CHECKS
do_clang_format()
{
+2 -1
View File
@@ -32,7 +32,8 @@
set -euo pipefail
readonly OT_BUILDDIR="${OT_BUILDDIR:-${PWD}/build}"
OT_BUILDDIR="${OT_BUILDDIR:-${PWD}/build}"
readonly OT_BUILDDIR
main()
{
+53 -19
View File
@@ -32,28 +32,62 @@
set -euo pipefail
readonly OT_BUILDDIR="${OT_BUILDDIR:-${PWD}/build}"
readonly OT_SRCDIR="${PWD}"
OT_BUILDDIR="${OT_BUILDDIR:-${PWD}/build}"
readonly OT_BUILDDIR
readonly OT_COLOR_PASS='\033[0;32m'
readonly OT_COLOR_FAIL='\033[0;31m'
readonly OT_COLOR_SKIP='\033[0;33m'
readonly OT_COLOR_NONE='\033[0m'
OT_SRCDIR="${PWD}"
readonly OT_SRCDIR
readonly OT_NODE_TYPE="${OT_NODE_TYPE:-cli}"
readonly OT_NATIVE_IP="${OT_NATIVE_IP:-0}"
readonly THREAD_VERSION="${THREAD_VERSION:-1.3}"
readonly INTER_OP="${INTER_OP:-0}"
readonly VERBOSE="${VERBOSE:-0}"
readonly BORDER_ROUTING="${BORDER_ROUTING:-1}"
readonly NAT64="${NAT64:-0}"
readonly NAT64_SERVICE="${NAT64_SERVICE:-openthread}"
readonly INTER_OP_BBR="${INTER_OP_BBR:-1}"
OT_COLOR_PASS='\033[0;32m'
readonly OT_COLOR_PASS
readonly OT_COREDUMP_DIR="${PWD}/ot-core-dump"
readonly FULL_LOGS=${FULL_LOGS:-0}
readonly TREL=${TREL:-0}
readonly LOCAL_OTBR_DIR=${LOCAL_OTBR_DIR:-""}
OT_COLOR_FAIL='\033[0;31m'
readonly OT_COLOR_FAIL
OT_COLOR_SKIP='\033[0;33m'
readonly OT_COLOR_SKIP
OT_COLOR_NONE='\033[0m'
readonly OT_COLOR_NONE
OT_NODE_TYPE="${OT_NODE_TYPE:-cli}"
readonly OT_NODE_TYPE
OT_NATIVE_IP="${OT_NATIVE_IP:-0}"
readonly OT_NATIVE_IP
THREAD_VERSION="${THREAD_VERSION:-1.3}"
readonly THREAD_VERSION
INTER_OP="${INTER_OP:-0}"
readonly INTER_OP
VERBOSE="${VERBOSE:-0}"
readonly VERBOSE
BORDER_ROUTING="${BORDER_ROUTING:-1}"
readonly BORDER_ROUTING
NAT64="${NAT64:-0}"
readonly NAT64
NAT64_SERVICE="${NAT64_SERVICE:-openthread}"
readonly NAT64_SERVICE
INTER_OP_BBR="${INTER_OP_BBR:-1}"
readonly INTER_OP_BBR
OT_COREDUMP_DIR="${PWD}/ot-core-dump"
readonly OT_COREDUMP_DIR
FULL_LOGS=${FULL_LOGS:-0}
readonly FULL_LOGS
TREL=${TREL:-0}
readonly TREL
LOCAL_OTBR_DIR=${LOCAL_OTBR_DIR:-""}
readonly LOCAL_OTBR_DIR
build_simulation()
{