Linux kbuild/kconfig development
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Hamdy Abou El Anein <info@daylightlinux.ch>
Cc: nsc@kernel.org, linux-kbuild@vger.kernel.org,
	linux-kernel@vger.kernel.org, irogers@google.com,
	tglx@kernel.org, peterz@infradead.org
Subject: Re: [PATCH] kbuild: reject nonzero checker exit status in checker-valid.sh
Date: Wed, 2 Dec 2026 14:59:09 -0700	[thread overview]
Message-ID: <20261202215909.GA2468262@ax162> (raw)
In-Reply-To: <20261201220057.12323-1-info@daylightlinux.ch>

On Tue, Dec 01, 2026 at 11:00:57PM +0100, Hamdy Abou El Anein wrote:
> The checker validation script only examines the output for the word
> "error". If the checker fails without printing that word, the pipeline
> still reports 1, and Kbuild treats the checker as functional.

Is this actually a problem in practice? All that would happen in this
scenario is that sparse would run and print errors to the console. I
think the current behavior is better because the user will see the
failure up front and either report it to us or address it if it is an
issue with their setup. checker-valid.sh is only looking for one
specific bug at the moment and I don't think that we should be
swallowing all problems with sparse in this check.

> Check the invocation's exit status before scanning its output. Retain
> the existing output check because sparse can return zero on error.
> 
> Tested using a mock checker that succeeds, fails silently, fails with
> a diagnostic, or reports an error while returning zero. Also verified
> that a missing checker is still rejected.
> 
> AI assistance: ChatGPT identified the bug by inspecting the script and
> prepared the fix, commit message and local regression tests.
> 
> Fixes: fd69b2f7d5f4 ("compiler: Use __typeof_unqual__() for __unqual_scalar_typeof()")
> Signed-off-by: Hamdy Abou El Anein <info@daylightlinux.ch>
> ---
>  scripts/checker-valid.sh | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/checker-valid.sh b/scripts/checker-valid.sh
> index 625a789ed1c8..38defc32cbd9 100755
> --- a/scripts/checker-valid.sh
> +++ b/scripts/checker-valid.sh
> @@ -14,6 +14,10 @@ static inline int u(const int *q)
>  }
>  EOF
>  
> -# sparse happily exits with 0 on error so validate
> -# there is none on stderr. Use awk as grep is a pain with sh -e
> -$@ $tmp_file 2>&1 | awk -v c=1 '/error/{c=0}END{print c}'
> +# Reject a failed checker invocation even if it prints no error.
> +# sparse may also exit with 0 on error, so inspect its output.
> +if output=$("$@" "$tmp_file" 2>&1); then
> +	printf '%s\n' "$output" | awk -v c=1 '/error/{c=0}END{print c}'
> +else
> +	echo 0
> +fi
> -- 
> 2.56.1
> 

-- 
Cheers,
Nathan

      reply	other threads:[~2026-12-02 21:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 22:00 [PATCH] kbuild: reject nonzero checker exit status in checker-valid.sh Hamdy Abou El Anein
2026-12-02 21:59 ` Nathan Chancellor [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202215909.GA2468262@ax162 \
    --to=nathan@kernel.org \
    --cc=info@daylightlinux.ch \
    --cc=irogers@google.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nsc@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox