summaryrefslogtreecommitdiff
path: root/scripts/lib
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2025-08-14 09:40:34 -0600
committerJonathan Corbet <corbet@lwn.net>2025-08-18 10:19:19 -0600
commite5d91662fcbac251dd17f04dbacf4d997939316e (patch)
treeb5367dd240dffddec20b02fc0169e81cd43d0b85 /scripts/lib
parentbf6b310d1b7e31a1cd6951eb75608a1d2876c04a (diff)
docs: kdoc: tighten up the pointer-to-function case
Tighten up the code and remove an unneeded regex operation. Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Link: https://lore.kernel.org/r/20250814154035.328769-7-corbet@lwn.net
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/kdoc/kdoc_parser.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser.py
index 7f4d95dd47d4..998b1ece932a 100644
--- a/scripts/lib/kdoc/kdoc_parser.py
+++ b/scripts/lib/kdoc/kdoc_parser.py
@@ -511,22 +511,21 @@ 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*' # Everything up to "(*"
+ r'([\w\[\].]*)' # Capture the name and possible [array]
+ r'\s*\)') # Make sure the trailing ")" is there
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, '')
+ 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.