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 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

+8 -9
+8 -9
scripts/lib/kdoc/kdoc_parser.py
··· 511 511 # Treat preprocessor directive as a typeless variable 512 512 self.push_parameter(ln, decl_type, arg, "", 513 513 "", declaration_name) 514 - 514 + # 515 + # The pointer-to-function case. 516 + # 515 517 elif KernRe(r'\(.+\)\s*\(').search(arg): 516 - # Pointer-to-function 517 - 518 518 arg = arg.replace('#', ',') 519 - 520 - r = KernRe(r'[^\(]+\(\*?\s*([\w\[\].]*)\s*\)') 519 + r = KernRe(r'[^\(]+\(\*?\s*' # Everything up to "(*" 520 + r'([\w\[\].]*)' # Capture the name and possible [array] 521 + r'\s*\)') # Make sure the trailing ")" is there 521 522 if r.match(arg): 522 523 param = r.group(1) 523 524 else: 524 525 self.emit_msg(ln, f"Invalid param: {arg}") 525 526 param = arg 526 - 527 - dtype = KernRe(r'([^\(]+\(\*?)\s*' + re.escape(param)).sub(r'\1', arg) 528 - self.push_parameter(ln, decl_type, param, dtype, 529 - arg, declaration_name) 527 + dtype = arg.replace(param, '') 528 + self.push_parameter(ln, decl_type, param, dtype, arg, declaration_name) 530 529 # 531 530 # The array-of-pointers case. Dig the parameter name out from the middle 532 531 # of the declaration.