commit:     c94b419216e44f9ff27f495003e9a0e50fd634b3
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Thu May 22 23:57:28 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri May 30 07:37:32 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=c94b4192

90gcc-warnings: convey warnings in a memory-efficient manner

Rather than synchronously slurp all of the warnings matched against the
contents of PORTAGE_LOG_FILE into a scalar variable before displaying,
read the warnings line by line while asynchronously calling eqawarn for
each. This may help to save memory in the case that many warnings are to
be displayed.

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 | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/bin/install-qa-check.d/90gcc-warnings 
b/bin/install-qa-check.d/90gcc-warnings
index bf749f74b6..571d6bd066 100644
--- a/bin/install-qa-check.d/90gcc-warnings
+++ b/bin/install-qa-check.d/90gcc-warnings
@@ -3,7 +3,7 @@
 # TODO: add -Wformat-security
 
 gcc_warn_check() {
-        local abort f reset_xtrace
+        local i reset_xtrace
         local -a msgs
 
        # Evaluate misc gcc warnings
@@ -147,7 +147,14 @@ gcc_warn_check() {
                #': warning: not enough variable arguments to fit a sentinel'
        )
 
-       f=$(
+       while read -r; do
+               if (( i++ == 0 )); then
+                       __vecho -ne '\n'
+                       eqawarn "QA Notice: Package triggers severe warnings 
which indicate that it"
+                       eqawarn "           may exhibit random runtime 
failures."
+               fi
+               eqawarn "${REPLY}"
+       done < <(
                # Coerce C as the character type for performance reasons, per
                # bug #160234. Coerce C as the collation to guarantee that
                # ranges are handled appropriately. Also, pass -a to GNU grep
@@ -164,26 +171,22 @@ gcc_warn_check() {
                | grep -E -a "${msgs[*]}" \
                | uniq
        )
-       if [[ -n ${f} ]] ; then
-               abort=1
 
-               __vecho -ne '\n'
-               eqawarn "QA Notice: Package triggers severe warnings which 
indicate that it"
-               eqawarn "           may exhibit random runtime failures."
-               eqawarn "${f}"
+       if (( i > 0 )); then
                __vecho -ne '\n'
        fi
 
        eval "${reset_xtrace}"
 
-       if (( abort )) ; then
-               echo "Please do not file a Gentoo bug and instead" \
-               "report the above QA issues directly to the upstream" \
-               "developers of this software." | fmt -w 70 | \
-               while read -r line ; do eqawarn "${line}" ; done
-               eqawarn "Homepage: ${HOMEPAGE}"
-               has stricter ${FEATURES} && \
+       if (( i > 0 )); then
+               while read -r; do eqawarn "${REPLY}"; done <<-EOF
+               Please do not file a Gentoo bug and instead report the above QA 
issues directly
+               to the upstream developers of this software.
+               Homepage: ${HOMEPAGE}
+               EOF
+               if has stricter ${FEATURES}; then
                        die "install aborted due to severe warnings shown above"
+               fi
        fi
 }
 

Reply via email to