commit:     52f303047696be5abbdda0ec2fa027274c57fe7c
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Thu May 22 17:01:47 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri May 30 07:37:29 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=52f30304

90gcc-warnings: hoist local declarations to top of function

This precedes a re-factoring. However, I would add that locals are not
lexically scoped in bash and that declaring them up-front tends to serve
as an effective canary for undue complexity. As a case in point, drop
the unused m variable.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/install-qa-check.d/90gcc-warnings | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/bin/install-qa-check.d/90gcc-warnings 
b/bin/install-qa-check.d/90gcc-warnings
index 80ec98af93..42166a7bf4 100644
--- a/bin/install-qa-check.d/90gcc-warnings
+++ b/bin/install-qa-check.d/90gcc-warnings
@@ -3,18 +3,19 @@
 # TODO: add -Wformat-security
 
 gcc_warn_check() {
-       local f
+        local abort always_overflow f gentoo_bug grep_cmd implicit_func_decl 
joined_msgs reset_debug
+        local -a msgs
 
        # Evaluate misc gcc warnings
        # In debug mode, this variable definition and corresponding grep calls
        # will produce false positives if they're shown in the trace.
-       local reset_debug=0
+       reset_debug=0
        if [[ $- == *x* ]] ; then
                set +x
                reset_debug=1
        fi
 
-       local m msgs=(
+       msgs=(
                # only will and does, no might :)
                'warning: .*will.*\[-Wstrict-aliasing\]'
                'warning: .*does.*\[-Wstrict-aliasing\]'
@@ -150,12 +151,11 @@ gcc_warn_check() {
        )
 
        # join all messages into one grep-expression
-       local joined_msgs
        printf -v joined_msgs '%s|' "${msgs[@]}"
        joined_msgs=${joined_msgs%|}
 
-       local abort="no"
-       local grep_cmd=grep
+       abort="no"
+       grep_cmd=grep
        [[ ${PORTAGE_LOG_FILE} = *.gz ]] && grep_cmd=zgrep
 
        # Force C locale to work around slow multibyte locales, bug #160234

Reply via email to