All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Donnefort <vdonnefort@google.com>
To: Joe Perches <joe@perches.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: Sun, 15 Nov 2026 16:39:11 +0000	[thread overview]
Message-ID: <avngL4BZlQTv2OHO@google.com> (raw)
In-Reply-To: <03c1afd39a3f167b960a982d1a933619855a975c.camel@perches.com>

On Sat, Nov 14, 2026 at 06:57:39AM -0800, Joe Perches wrote:
> On Sat, 2026-11-14 at 06:26 -0800, Joe Perches wrote:
> > > How about matching one internal () pair?
> > > 
> > > __guarded_by\s*\(
> > > 	(?:
> > > 		[^()]++ |
> > > 		\([^()]*+\)
> > > 	)*+
> > > \)
> > 
> > Sure.
> > Please add and use another variable so it's not repeated everywhere.
> 
> Reading a bit about balanced parentheses in perl '(?R)'
> non capturing recursion works since 5.10.0
> 
> Maybe instead use
> 
> /\((?:[^()]++|(?R))*\)/

Somehow it doesn't work. I have tried the following:

  my $p = qr/\((?:[^()]++|(?R))*\)/;
  my $a = qr/__guarded_by\s*$p/;
  for my $s ("__guarded_by(&mutex)", "__guarded_by(foobar())") {
  	print "$s:", ($s =~ /^$a$/ ? "ok" : "nope"), "\n";
  }'

  __guarded_by(&mutex): ok
  __guarded_by(foobar()): nope

Did I miss something?

-- 
Vincent

> 
> and I should probably rework all of checkpatch's uses of
> $balanced_parens to avoid all those weird capture group uses
> as it was originally written for perl 5.8 (thanks akpm)

  reply	other threads:[~2026-11-15 16:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 15:12 [PATCH v1] checkpatch: Add context-analysis attributes 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
2026-11-14 14:57       ` Joe Perches
2026-11-15 16:39         ` Vincent Donnefort [this message]
2026-11-16  4:18           ` 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=avngL4BZlQTv2OHO@google.com \
    --to=vdonnefort@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=elver@google.com \
    --cc=joe@perches.com \
    --cc=kernel-team@android.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.