mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Vincent Donnefort <vdonnefort@google.com>
Cc: apw@canonical.com, akpm@linux-foundation.org, elver@google.com,
	 linux-kernel@vger.kernel.org, kernel-team@android.com
Subject: Re: [PATCH v1] checkpatch: Add context-analysis attributes
Date: Sat, 14 Nov 2026 06:26:10 -0800	[thread overview]
Message-ID: <61e4f8997861a1188935435e78682c575552d2a3.camel@perches.com> (raw)
In-Reply-To: <avhgY9t0KVkDfEZw@google.com>

On Sat, 2026-11-14 at 13:21 +0000, Vincent Donnefort wrote:
> On Thu, Nov 12, 2026 at 07:32:14PM -0800, Joe Perches wrote:
> > On Thu, 2026-11-12 at 15:12 +0000, Vincent Donnefort wrote:
> > > Checkpatch doesn't know about the context analysis attributes and
> > > misparses annotated declarations (e.g. mistaking __guarded_by() fields
> > > for extern prototype). Add them to the known attributes list.
> > 
> > Nak.
> > 
> > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > []
> > > @@ -526,6 +526,25 @@ our $InitAttributeData = qr{$InitAttributePrefix(?:initdata\b)};
> > >  our $InitAttributeConst = qr{$InitAttributePrefix(?:initconst\b)};
> > >  our $InitAttributeInit = qr{$InitAttributePrefix(?:init\b)};
> > >  our $InitAttribute = qr{$InitAttributeData|$InitAttributeConst|$InitAttributeInit};
> > > +our $ContextAnalysis = qr{
> > 
> > Are all of these from include/linux/compiler-context-analysis.h ?
>  
> Correct, except __rcu_guarded, which I can drop.

Not necessary really, it uses __guarded_by internally.

> > 
> > > +			__guarded_by\b|
> > 
> > __guarded_by takes an argument so it should be
> > 
> > 			__guarded_by\s*\(.*\)
> > 
> > like the __aligned use below in $Attribute
> > 
> > > +			__pt_guarded_by\b|
> > 
> > And all the rest of these entries that take arguments need to add
> > that same '\s*\(.*\)'
> > 
> > and it'll be fragile besides, multiline uses likely won't work,
> > any use that has another internal () pair won't work, etc...;
> 
> How about matching one internal () pair?
> 
> __guarded_by\s*\(
> 	(?:
> 		[^()]++ |
> 		\([^()]*+\)
> 	)*+
> \)

Sure.
Please add and use another variable so it's not repeated everywhere.

  reply	other threads:[~2026-11-14 14:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 15:12 Vincent Donnefort
2026-11-12 15:23 ` Marco Elver
2026-11-13  3:32 ` Joe Perches
2026-11-14 13:21   ` Vincent Donnefort
2026-11-14 14:26     ` Joe Perches [this message]
2026-11-14 14:57       ` Joe Perches

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=61e4f8997861a1188935435e78682c575552d2a3.camel@perches.com \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=elver@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vdonnefort@google.com \
    /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®