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: ensure that comments are dropped before calling split_struct_proto()

Changeset 2b957decdb6c ("docs: kdoc: don't add broken comments inside prototypes")
revealed a hidden bug at split_struct_proto(): some comments there may break
its capability of properly identifying a struct.

Fixing it is as simple as stripping comments before calling it.

Fixes: 2b957decdb6c ("docs: kdoc: don't add broken comments inside prototypes")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <dcff37b6da5329aea415de31f543b6a1c2cbbbce.1773770483.git.mchehab+huawei@kernel.org>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
12aa7753 827b9458

+4 -2
+4 -2
tools/lib/python/kdoc/kdoc_parser.py
··· 723 723 # 724 724 # Do the basic parse to get the pieces of the declaration. 725 725 # 726 + proto = trim_private_members(proto) 726 727 struct_parts = self.split_struct_proto(proto) 727 728 if not struct_parts: 728 729 self.emit_msg(ln, f"{proto} error: Cannot parse struct or union!") ··· 764 763 # Strip preprocessor directives. Note that this depends on the 765 764 # trailing semicolon we added in process_proto_type(). 766 765 # 766 + proto = trim_private_members(proto) 767 767 proto = KernRe(r'#\s*((define|ifdef|if)\s+|endif)[^;]*;', flags=re.S).sub('', proto) 768 768 # 769 769 # Parse out the name and members of the enum. Typedef form first. ··· 772 770 r = KernRe(r'typedef\s+enum\s*\{(.*)\}\s*(\w*)\s*;') 773 771 if r.search(proto): 774 772 declaration_name = r.group(2) 775 - members = trim_private_members(r.group(1)) 773 + members = r.group(1) 776 774 # 777 775 # Failing that, look for a straight enum 778 776 # ··· 780 778 r = KernRe(r'enum\s+(\w*)\s*\{(.*)\}') 781 779 if r.match(proto): 782 780 declaration_name = r.group(1) 783 - members = trim_private_members(r.group(2)) 781 + members = r.group(2) 784 782 # 785 783 # OK, this isn't going to work. 786 784 #