From: Joe Perches <joe@perches.com>
To: alison.schofield@intel.com, Andy Whitcroft <apw@canonical.com>,
Dwaipayan Ray <dwaipayanray1@gmail.com>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Dan Williams <dan.j.williams@intel.com>,
linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] checkpatch: allow an assignment in if condition for ACQUIRE_ERR()
Date: Wed, 13 Aug 2025 00:17:51 -0700 [thread overview]
Message-ID: <9afd4c898a194cd576f1aaa08b72c67d4e538cc7.camel@perches.com> (raw)
In-Reply-To: <20250813003821.2891532-1-alison.schofield@intel.com>
On Tue, 2025-08-12 at 17:38 -0700, alison.schofield@intel.com wrote:
> From: Alison Schofield <alison.schofield@intel.com>
>
> New helpers, ACQUIRE() and ACQUIRE_ERR(), were recently introduced to
> clean up conditional locking paths [1].
[]
> That compact format was a deliberate choice by the authors. By making
> this a checkpatch exception, existing ERRORs are quieted, and future
> users of the macro will not be dissuaded by checkpatch from using the
> preferred compact format.
not stylish IMO.
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -5696,7 +5696,14 @@ sub process {
> my ($s, $c) = ($stat, $cond);
> my $fixed_assign_in_if = 0;
>
> - if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/s) {
> + if ($c =~ /\bif\s*\((.*[^<>!=]=[^=].*)\)/s) {
> + my $expr = $1;
> +
> + # Allow ACQUIRE_ERR() macro syntax
> + if ($expr =~ /\w+\s*=\s*ACQUIRE_ERR\s*\(/) {
> + next;
> + }
nak.
Using next would not do any additional checks on this line.
Likely use basic block or a constuct like
if ($c =~ /\bif\s*\((.*[^<>!=]=[^=].*)/s &&
$1 !~ /\bACQUIRE_ERR\b/) {
and perhaps the \w+ should be $Lval
> +
> if (ERROR("ASSIGN_IN_IF",
> "do not use assignment in if condition\n" . $herecurr) &&
> $fix && $perl_version_ok) {
next prev parent reply other threads:[~2025-08-13 7:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 0:38 alison.schofield
2025-08-13 7:17 ` Joe Perches [this message]
2025-08-15 0:36 ` Alison Schofield
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=9afd4c898a194cd576f1aaa08b72c67d4e538cc7.camel@perches.com \
--to=joe@perches.com \
--cc=alison.schofield@intel.com \
--cc=apw@canonical.com \
--cc=dan.j.williams@intel.com \
--cc=dwaipayanray1@gmail.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
--cc=peterz@infradead.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®