From: Nguyen Dinh Phi <phind.uet@gmail.com>
To: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>
Cc: Nguyen Dinh Phi <phind.uet@gmail.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] checkpatch: check parenthesis alignment against unmodified anchor lines
Date: Wed, 19 Aug 2026 00:40:10 +0800 [thread overview]
Message-ID: <20260818164011.1313164-1-phind.uet@gmail.com> (raw)
The PARENTHESIS_ALIGNMENT check only compares a continuation line's
indentation against the previous line when that previous line was
itself added by the patch (prefixed with '+'). If a patch touches
only the continuation line of a wrapped condition and leaves the
line with the opening parenthesis as unmodified context, the check
is silently skipped even though alignment is broken.
For example, this hunk drops a stale sk_err check but breaks
parenthesis alignment on the remaining continuation line, while the
anchor "while (" line stays as context:
while ((connected = vsock_dequeue_accept(listener)) == NULL &&
- listener->sk_err == 0 && timeout != 0) {
+ timeout != 0) {
checkpatch --strict reports "0 checks" for this hunk because the
anchor line is unchanged context rather than a '+' line, so the
regex matching it never fires.
Relax the anchor-line match to also accept unmodified context lines,
so alignment is still checked against an anchor line the patch
itself didn't touch. Keep the check scoped to lines the patch
actually changes by requiring the current line to start with '+', so
pairs of untouched context lines are not newly flagged.
Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
Assisted-by: Claude:claude-sonnet-5
---
scripts/checkpatch.pl | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f424dafce5bc..589fa6572d95 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4057,9 +4057,12 @@ sub process {
}
# check multi-line statement indentation matches previous line
+# (the anchor line may be unchanged context when only a continuation
+# line of the statement is touched by this patch)
if ($perl_version_ok &&
- $prevline =~ /^\+([ \t]*)((?:$c90_Keywords(?:\s+if)\s*)|(?:$Declare\s*)?(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*|(?:\*\s*)*$Lval\s*=\s*$Ident\s*)\(.*(\&\&|\|\||,)\s*$/) {
- $prevline =~ /^\+(\t*)(.*)$/;
+ $line =~ /^\+/ &&
+ $prevline =~ /^[\+ ]([ \t]*)((?:$c90_Keywords(?:\s+if)\s*)|(?:$Declare\s*)?(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*|(?:\*\s*)*$Lval\s*=\s*$Ident\s*)\(.*(\&\&|\|\||,)\s*$/) {
+ $prevline =~ /^[\+ ](\t*)(.*)$/;
my $oldindent = $1;
my $rest = $2;
--
2.53.0
reply other threads:[~2026-08-18 16:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260818164011.1313164-1-phind.uet@gmail.com \
--to=phind.uet@gmail.com \
--cc=apw@canonical.com \
--cc=joe@perches.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.