[PATCH 2/7] docs: kdoc: tidy up space removal in create_parameter_list()

Jonathan Corbet posted 7 patches 1 month, 3 weeks ago
[PATCH 2/7] docs: kdoc: tidy up space removal in create_parameter_list()
Posted by Jonathan Corbet 1 month, 3 weeks ago
Remove a redundant test and add a comment describing what the space removal
is doing.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
---
 scripts/lib/kdoc/kdoc_parser.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser.py
index 96e3fe4ec431..53051ce831ba 100644
--- a/scripts/lib/kdoc/kdoc_parser.py
+++ b/scripts/lib/kdoc/kdoc_parser.py
@@ -545,12 +545,14 @@ class KernelDoc:
                                     arg, declaration_name)
 
             elif arg:
+                #
+                # Clean up extraneous spaces and split the string at commas; the first
+                # element of the resulting list will also include the type information.
+                #
                 arg = KernRe(r'\s*:\s*').sub(":", arg)
                 arg = KernRe(r'\s*\[').sub('[', arg)
-
                 args = KernRe(r'\s*,\s*').split(arg)
-                if args[0] and '*' in args[0]:
-                    args[0] = re.sub(r'(\*+)\s*', r' \1', args[0])
+                args[0] = re.sub(r'(\*+)\s*', r' \1', args[0])
 
                 first_arg = []
                 r = KernRe(r'^(.*\s+)(.*?\[.*\].*)$')
-- 
2.50.1
Re: [PATCH 2/7] docs: kdoc: tidy up space removal in create_parameter_list()
Posted by Mauro Carvalho Chehab 1 month, 3 weeks ago
On Tue, 12 Aug 2025 13:57:43 -0600
Jonathan Corbet <corbet@lwn.net> wrote:

> Remove a redundant test and add a comment describing what the space removal
> is doing.
> 
> Signed-off-by: Jonathan Corbet <corbet@lwn.net>

LGTM.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

> ---
>  scripts/lib/kdoc/kdoc_parser.py | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser.py
> index 96e3fe4ec431..53051ce831ba 100644
> --- a/scripts/lib/kdoc/kdoc_parser.py
> +++ b/scripts/lib/kdoc/kdoc_parser.py
> @@ -545,12 +545,14 @@ class KernelDoc:
>                                      arg, declaration_name)
>  
>              elif arg:
> +                #
> +                # Clean up extraneous spaces and split the string at commas; the first
> +                # element of the resulting list will also include the type information.
> +                #
>                  arg = KernRe(r'\s*:\s*').sub(":", arg)
>                  arg = KernRe(r'\s*\[').sub('[', arg)
> -
>                  args = KernRe(r'\s*,\s*').split(arg)
> -                if args[0] and '*' in args[0]:
> -                    args[0] = re.sub(r'(\*+)\s*', r' \1', args[0])
> +                args[0] = re.sub(r'(\*+)\s*', r' \1', args[0])
>  
>                  first_arg = []
>                  r = KernRe(r'^(.*\s+)(.*?\[.*\].*)$')



Thanks,
Mauro