mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
To: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>
Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
Subject: [PATCH 3/4] checkpatch: don't stop at the first empty input
Date: Sun, 08 Nov 2026 04:21:04 +0000	[thread overview]
Message-ID: <20261108-checkpatch-fixes-hash-v1-3-d49b3085c20b@oss.qualcomm.com> (raw)
In-Reply-To: <20261108-checkpatch-fixes-hash-v1-0-d49b3085c20b@oss.qualcomm.com>

When checkpatch is given multiple inputs, process() calls exit(0) as
soon as it encounters an empty one. This discards the failure status
of inputs already checked, and the remaining inputs are never checked.

E.g. a patch with a bogus Fixes: tag followed by an empty file reports
the warning, but the run is still reported as successful:

  $ ./scripts/checkpatch.pl -q --terse bad.patch empty.patch
  bad.patch:9: WARNING: Unknown commit id '6393a36fe184', ...
  total: 0 errors, 1 warnings, 7 lines checked
  $ echo $?
  0

With the order reversed, bad.patch is never checked at all.

The same happens with --file when one of the files doesn't exist, as
the diff against /dev/null then produces no output. A mistyped file
name therefore causes all following files to be silently skipped:

  $ ./scripts/checkpatch.pl -q --terse -f missing.c existing.c
  diff: missing.c: No such file or directory
  $ echo $?
  0

Return from process() instead, so the empty input is still silently
skipped while the remaining inputs are checked and the exit status
reflects all of them.

Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 45279c17f70a..a5e6f96477c3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -7874,7 +7874,7 @@ sub process {
 	# If we have no input at all, then there is nothing to report on
 	# so just keep quiet.
 	if ($#rawlines == -1) {
-		exit(0);
+		return 1;
 	}
 
 	# In mailback mode only produce a report in the negative, for

-- 
2.55.0


  parent reply	other threads:[~2026-11-08  4:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-08  4:21 [PATCH 0/4] checkpatch: improve exit criterias Bjorn Andersson
2026-11-08  4:21 ` [PATCH 1/4] checkpatch: don't stop at the first clean patch with --mailback Bjorn Andersson
2026-11-08  4:21 ` [PATCH 2/4] checkpatch: don't stop at the first non-patch input with --no-patch Bjorn Andersson
2026-11-08  4:21 ` Bjorn Andersson [this message]
2026-11-08  4:21 ` [PATCH 4/4] checkpatch: fail on missing or unreadable files with --file Bjorn Andersson

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=20261108-checkpatch-fixes-hash-v1-3-d49b3085c20b@oss.qualcomm.com \
    --to=bjorn.andersson@oss.qualcomm.com \
    --cc=apw@canonical.com \
    --cc=joe@perches.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.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

all inboxes | Powered by JetHome®