From ee4b0d7419974b0605bed80814d3d22478edf98d Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Thu, 28 Mar 2019 15:23:53 -0400 Subject: libs/project: Set max loop iteration in for loop --- libs/project | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libs/project b/libs/project index 70a76d71..083cfcd8 100755 --- a/libs/project +++ b/libs/project @@ -75,10 +75,9 @@ project_dependencies_check() { local -a dependencies mapfile -t dependencies < <(project_dependencies "$project" "$@") - local -i count=${#dependencies[@]} local -i missing=0 - for ((i = 0; i < count; i++)); do + for ((i = 0, nodeps = ${#dependencies[@]}; i < nodeps; ++i)); do local -a dependency=(${dependencies[i]}) project_check "${dependency[0]}" || let missing++ @@ -94,14 +93,13 @@ project_dependencies_sources_check() { local -a dependencies mapfile -t dependencies < <(project_dependencies "$project" "$@") - local -i count=${#dependencies[@]} local -i missing=0 - for ((i = 0; i < count; i++)); do + for ((i = 0, nodeps = ${#dependencies[@]}; i < nodeps; ++i)); do local -a dependency=(${dependencies[i]}) - project_sources_directory_filled_check "${dependency[0]}" \ - || let missing++ + project_sources_directory_filled_check "${dependency[0]}" || + let missing++ done return $missing @@ -115,9 +113,7 @@ project_dependencies_action_arguments() { local -a dependencies mapfile -t dependencies < <(project_dependencies "$project" "$@") - local -i count=${#dependencies[@]} - - for ((i = 0; i < count; i++)); do + for ((i = 0, nodeps = ${#dependencies[@]}; i < nodeps; ++i)); do local -a dependency=(${dependencies[i]}) if project_function_check "${dependency[0]}" "$action"; then -- cgit v1.2.3-70-g09d2 From 56c93461865222e50915e380b99a34fd4890170e Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Thu, 28 Mar 2019 15:25:33 -0400 Subject: libreboot: Set max loop iteration in for loop --- libreboot | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libreboot b/libreboot index 2f3a3ffe..30ea9f63 100755 --- a/libreboot +++ b/libreboot @@ -155,12 +155,11 @@ libreboot_setup_include() { } libreboot_setup_tool_actions() { - local -i tool_actions_count="${#TOOL_ACTIONS_GENERIC[@]}" local ignore="${TOOL_ACTIONS_GENERIC_IGNORE_CHECK[*]}" local -a tool_actions - for ((i=0; i<"$tool_actions_count"; i++)); do + for ((i=0, nogeneric=${#TOOL_ACTIONS_GENERIC[@]}; i Date: Thu, 28 Mar 2019 14:33:52 -0400 Subject: let's prefer pre-increment The "let" builtin returns 1 if it's given an argument that evaluates to zero. --- libs/project | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/project b/libs/project index 083cfcd8..f2692cd6 100755 --- a/libs/project +++ b/libs/project @@ -80,7 +80,7 @@ project_dependencies_check() { for ((i = 0, nodeps = ${#dependencies[@]}; i < nodeps; ++i)); do local -a dependency=(${dependencies[i]}) - project_check "${dependency[0]}" || let missing++ + project_check "${dependency[0]}" || let ++missing done return $missing @@ -99,7 +99,7 @@ project_dependencies_sources_check() { local -a dependency=(${dependencies[i]}) project_sources_directory_filled_check "${dependency[0]}" || - let missing++ + let ++missing done return $missing -- cgit v1.2.3-70-g09d2