From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Akira Yokosawa <akiyks@gmail.com>
Subject: Re: [PATCH 6/7] docs: kdoc: tighten up the pointer-to-function case
Date: Wed, 13 Aug 2025 00:39:02 +0200 [thread overview]
Message-ID: <20250813003902.2fc82b54@foz.lan> (raw)
In-Reply-To: <20250812195748.124402-7-corbet@lwn.net>
On Tue, 12 Aug 2025 13:57:47 -0600
Jonathan Corbet <corbet@lwn.net> wrote:
> Tighten up the code and remove an unneeded regex operation.
>
> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
> ---
> scripts/lib/kdoc/kdoc_parser.py | 15 ++++++---------
> 1 file changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser.py
> index d7fb79a64487..ceb38b59fb4c 100644
> --- a/scripts/lib/kdoc/kdoc_parser.py
> +++ b/scripts/lib/kdoc/kdoc_parser.py
> @@ -511,22 +511,19 @@ class KernelDoc:
> # Treat preprocessor directive as a typeless variable
> self.push_parameter(ln, decl_type, arg, "",
> "", declaration_name)
> -
> + #
> + # The pointer-to-function case.
> + #
> elif KernRe(r'\(.+\)\s*\(').search(arg):
> - # Pointer-to-function
> -
> arg = arg.replace('#', ',')
> -
> - r = KernRe(r'[^\(]+\(\*?\s*([\w\[\].]*)\s*\)')
> + r = KernRe(r'[^\(]+\(\*?\s*' r'([\w\[\].]*)' r'\s*\)')
Heh, it took me a couple of seconds to understand this concat, as I haven't
seem concat pattern like that before (maybe except for some old C book
I read a millennium ago that I barely remember). So, IMO, it became harder
to understand this way. I would either remove the extra two ' r' from the
string or write it as:
r = KernRe(r'[^\(]+\(\*?\s*'
r'([\w\[\].]*)'
r'\s*\)')
Eventually adding a comment for the capture group.
With that, feel free to add:
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> if r.match(arg):
> param = r.group(1)
> else:
> self.emit_msg(ln, f"Invalid param: {arg}")
> param = arg
> -
> - dtype = KernRe(r'([^\(]+\(\*?)\s*' + re.escape(param)).sub(r'\1', arg)
> - self.push_parameter(ln, decl_type, param, dtype,
> - arg, declaration_name)
> + dtype = arg.replace(param, '')
Nice cleanup.
> + self.push_parameter(ln, decl_type, param, dtype, arg, declaration_name)
> #
> # The array-of-pointers case. Dig the parameter name out from the middle
> # of the declaration.
Thanks,
Mauro
next prev parent reply other threads:[~2025-08-12 22:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 19:57 [PATCH 0/7] docs: kdoc: tidy up create_parameter_list() somewhat Jonathan Corbet
2025-08-12 19:57 ` [PATCH 1/7] docs: kdoc: remove dead code Jonathan Corbet
2025-08-12 22:43 ` Mauro Carvalho Chehab
2025-08-12 19:57 ` [PATCH 2/7] docs: kdoc: tidy up space removal in create_parameter_list() Jonathan Corbet
2025-08-12 22:44 ` Mauro Carvalho Chehab
2025-08-12 19:57 ` [PATCH 3/7] docs: kdoc: clean up the create_parameter_list() "first arg" logic Jonathan Corbet
2025-08-12 23:17 ` Mauro Carvalho Chehab
2025-08-13 15:46 ` Jonathan Corbet
2025-08-12 19:57 ` [PATCH 4/7] docs: kdoc: add a couple more comments in create_parameter_list() Jonathan Corbet
2025-08-12 22:47 ` Mauro Carvalho Chehab
2025-08-12 19:57 ` [PATCH 5/7] docs: kdoc: tighten up the array-of-pointers case Jonathan Corbet
2025-08-12 22:53 ` Mauro Carvalho Chehab
2025-08-13 15:16 ` Jonathan Corbet
2025-08-12 19:57 ` [PATCH 6/7] docs: kdoc: tighten up the pointer-to-function case Jonathan Corbet
2025-08-12 22:39 ` Mauro Carvalho Chehab [this message]
2025-08-12 23:22 ` Jonathan Corbet
2025-08-13 9:02 ` Mauro Carvalho Chehab
2025-08-12 19:57 ` [PATCH 7/7] docs: kdoc: remove redundant comment stripping Jonathan Corbet
2025-08-12 23:19 ` Mauro Carvalho Chehab
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=20250813003902.2fc82b54@foz.lan \
--to=mchehab+huawei@kernel.org \
--cc=akiyks@gmail.com \
--cc=corbet@lwn.net \
--cc=linux-doc@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;
as well as URLs for NNTP newsgroup(s).