]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
docs: kdoc: tighten up the array-of-pointers case
authorJonathan Corbet <corbet@lwn.net>
Thu, 14 Aug 2025 15:40:33 +0000 (09:40 -0600)
committerJonathan Corbet <corbet@lwn.net>
Mon, 18 Aug 2025 16:19:19 +0000 (10:19 -0600)
Simplify one gnarly regex and remove another altogether; add a comment
describing what is going on.  There will be no #-substituted commas in this
case, so don't bother trying to put them back.

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-6-corbet@lwn.net
scripts/lib/kdoc/kdoc_parser.py

index 29881757bf1c9fcde8758ef76223d07305d67b6c..7f4d95dd47d4facafd907d80cbc4e0ea9ea4c384 100644 (file)
@@ -527,23 +527,21 @@ class KernelDoc:
                 dtype = KernRe(r'([^\(]+\(\*?)\s*' + re.escape(param)).sub(r'\1', arg)
                 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.
+            #
             elif KernRe(r'\(.+\)\s*\[').search(arg):
-                # Array-of-pointers
-
-                arg = arg.replace('#', ',')
-                r = KernRe(r'[^\(]+\(\s*\*\s*([\w\[\].]*?)\s*(\s*\[\s*[\w]+\s*\]\s*)*\)')
+                r = KernRe(r'[^\(]+\(\s*\*\s*'         # Up to "(" and maybe "*"
+                           r'([\w.]*?)'                        # The actual pointer name
+                           r'\s*(\[\s*\w+\s*\]\s*)*\)') # The [array portion]
                 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)
             elif arg:
                 #
                 # Clean up extraneous spaces and split the string at commas; the first