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: clean up the create_parameter_list() "first arg" logic

The logic for finding the name of the first in a series of variable names
is somewhat convoluted and, in the use of .extend(), actively buggy.
Document what is happening and simplify the logic.

Acked-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250814154035.328769-4-corbet@lwn.net

+11 -11
+11 -11
scripts/lib/kdoc/kdoc_parser.py
··· 553 553 arg = KernRe(r'\s*\[').sub('[', arg) 554 554 args = KernRe(r'\s*,\s*').split(arg) 555 555 args[0] = re.sub(r'(\*+)\s*', r' \1', args[0]) 556 - 557 - first_arg = [] 558 - r = KernRe(r'^(.*\s+)(.*?\[.*\].*)$') 559 - if args[0] and r.match(args[0]): 560 - args.pop(0) 561 - first_arg.extend(r.group(1)) 562 - first_arg.append(r.group(2)) 556 + # 557 + # args[0] has a string of "type a". If "a" includes an [array] 558 + # declaration, we want to not be fooled by any white space inside 559 + # the brackets, so detect and handle that case specially. 560 + # 561 + r = KernRe(r'^([^[\]]*\s+)(.*)$') 562 + if r.match(args[0]): 563 + args[0] = r.group(2) 564 + dtype = r.group(1) 563 565 else: 564 - first_arg = KernRe(r'\s+').split(args.pop(0)) 565 - 566 - args.insert(0, first_arg.pop()) 567 - dtype = ' '.join(first_arg) 566 + # No space in args[0]; this seems wrong but preserves previous behavior 567 + dtype = '' 568 568 569 569 bitfield_re = KernRe(r'(.*?):(\w+)') 570 570 for param in args: