Skip to content

Commit 172bee3

Browse files
author
Jonathan Corbet
committed
docs: kdoc: remove the "struct_actual" machinery
The code goes out of its way to create a special list of parameters in entry.struct_actual that is just like entry.parameterlist, but with extra junk. The only use of that information, in check_sections(), promptly strips all the extra junk back out. Drop all that extra work and just use parameterlist. No output changes. Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
1 parent 8d73387 commit 172bee3

1 file changed

Lines changed: 2 additions & 30 deletions

File tree

scripts/lib/kdoc/kdoc_parser.py

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ def __init__(self, config, ln):
116116

117117
self._contents = []
118118
self.sectcheck = ""
119-
self.struct_actual = ""
120119
self.prototype = ""
121120

122121
self.warnings = []
@@ -366,15 +365,6 @@ def push_parameter(self, ln, decl_type, param, dtype,
366365
org_arg = KernRe(r'\s\s+').sub(' ', org_arg)
367366
self.entry.parametertypes[param] = org_arg
368367

369-
def save_struct_actual(self, actual):
370-
"""
371-
Strip all spaces from the actual param so that it looks like
372-
one string item.
373-
"""
374-
375-
actual = KernRe(r'\s*').sub("", actual, count=1)
376-
377-
self.entry.struct_actual += actual + " "
378368

379369
def create_parameter_list(self, ln, decl_type, args,
380370
splitter, declaration_name):
@@ -420,7 +410,6 @@ def create_parameter_list(self, ln, decl_type, args,
420410
param = arg
421411

422412
dtype = KernRe(r'([^\(]+\(\*?)\s*' + re.escape(param)).sub(r'\1', arg)
423-
self.save_struct_actual(param)
424413
self.push_parameter(ln, decl_type, param, dtype,
425414
arg, declaration_name)
426415

@@ -437,7 +426,6 @@ def create_parameter_list(self, ln, decl_type, args,
437426

438427
dtype = KernRe(r'([^\(]+\(\*?)\s*' + re.escape(param)).sub(r'\1', arg)
439428

440-
self.save_struct_actual(param)
441429
self.push_parameter(ln, decl_type, param, dtype,
442430
arg, declaration_name)
443431

@@ -470,7 +458,6 @@ def create_parameter_list(self, ln, decl_type, args,
470458

471459
param = r.group(1)
472460

473-
self.save_struct_actual(r.group(2))
474461
self.push_parameter(ln, decl_type, r.group(2),
475462
f"{dtype} {r.group(1)}",
476463
arg, declaration_name)
@@ -482,12 +469,10 @@ def create_parameter_list(self, ln, decl_type, args,
482469
continue
483470

484471
if dtype != "": # Skip unnamed bit-fields
485-
self.save_struct_actual(r.group(1))
486472
self.push_parameter(ln, decl_type, r.group(1),
487473
f"{dtype}:{r.group(2)}",
488474
arg, declaration_name)
489475
else:
490-
self.save_struct_actual(param)
491476
self.push_parameter(ln, decl_type, param, dtype,
492477
arg, declaration_name)
493478

@@ -499,24 +484,11 @@ def check_sections(self, ln, decl_name, decl_type, sectcheck, prmscheck):
499484

500485
sects = sectcheck.split()
501486
prms = prmscheck.split()
502-
err = False
503487

504488
for sx in range(len(sects)): # pylint: disable=C0200
505489
err = True
506490
for px in range(len(prms)): # pylint: disable=C0200
507-
prm_clean = prms[px]
508-
prm_clean = KernRe(r'\[.*\]').sub('', prm_clean)
509-
prm_clean = attribute.sub('', prm_clean)
510-
511-
# ignore array size in a parameter string;
512-
# however, the original param string may contain
513-
# spaces, e.g.: addr[6 + 2]
514-
# and this appears in @prms as "addr[6" since the
515-
# parameter list is split at spaces;
516-
# hence just ignore "[..." for the sections check;
517-
prm_clean = KernRe(r'\[.*').sub('', prm_clean)
518-
519-
if prm_clean == sects[sx]:
491+
if prms[px] == sects[sx]:
520492
err = False
521493
break
522494

@@ -782,7 +754,7 @@ def dump_struct(self, ln, proto):
782754
self.create_parameter_list(ln, decl_type, members, ';',
783755
declaration_name)
784756
self.check_sections(ln, declaration_name, decl_type,
785-
self.entry.sectcheck, self.entry.struct_actual)
757+
self.entry.sectcheck, ' '.join(self.entry.parameterlist))
786758

787759
# Adjust declaration for better display
788760
declaration = KernRe(r'([\{;])').sub(r'\1\n', declaration)

0 commit comments

Comments
 (0)