Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs: kdoc: tighten up the array-of-pointers case

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

+9 -11
+9 -11
scripts/lib/kdoc/kdoc_parser.py
··· 527 527 dtype = KernRe(r'([^\(]+\(\*?)\s*' + re.escape(param)).sub(r'\1', arg) 528 528 self.push_parameter(ln, decl_type, param, dtype, 529 529 arg, declaration_name) 530 - 530 + # 531 + # The array-of-pointers case. Dig the parameter name out from the middle 532 + # of the declaration. 533 + # 531 534 elif KernRe(r'\(.+\)\s*\[').search(arg): 532 - # Array-of-pointers 533 - 534 - arg = arg.replace('#', ',') 535 - r = KernRe(r'[^\(]+\(\s*\*\s*([\w\[\].]*?)\s*(\s*\[\s*[\w]+\s*\]\s*)*\)') 535 + r = KernRe(r'[^\(]+\(\s*\*\s*' # Up to "(" and maybe "*" 536 + r'([\w.]*?)' # The actual pointer name 537 + r'\s*(\[\s*\w+\s*\]\s*)*\)') # The [array portion] 536 538 if r.match(arg): 537 539 param = r.group(1) 538 540 else: 539 541 self.emit_msg(ln, f"Invalid param: {arg}") 540 542 param = arg 541 - 542 - dtype = KernRe(r'([^\(]+\(\*?)\s*' + re.escape(param)).sub(r'\1', arg) 543 - 544 - self.push_parameter(ln, decl_type, param, dtype, 545 - arg, declaration_name) 546 - 543 + dtype = arg.replace(param, '') 544 + self.push_parameter(ln, decl_type, param, dtype, arg, declaration_name) 547 545 elif arg: 548 546 # 549 547 # Clean up extraneous spaces and split the string at commas; the first