[PATCH 4/7] docs: kdoc: add a couple more comments in create_parameter_list()

Jonathan Corbet posted 7 patches 1 month, 3 weeks ago
[PATCH 4/7] docs: kdoc: add a couple more comments in create_parameter_list()
Posted by Jonathan Corbet 1 month, 3 weeks ago
Make what the final code is doing a bit more clear to slow readers like me.

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

diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser.py
index 47f7ea01ed10..36c4035343dc 100644
--- a/scripts/lib/kdoc/kdoc_parser.py
+++ b/scripts/lib/kdoc/kdoc_parser.py
@@ -568,12 +568,18 @@ class KernelDoc:
 
                 bitfield_re = KernRe(r'(.*?):(\w+)')
                 for param in args:
+                    #
+                    # For pointers, shift the star(s) from the variable name to the
+                    # type declaration.
+                    #
                     r = KernRe(r'^(\*+)\s*(.*)')
                     if r.match(param):
                         self.push_parameter(ln, decl_type, r.group(2),
                                             f"{dtype} {r.group(1)}",
                                             arg, declaration_name)
-
+                    #
+                    # Perform a similar shift for bitfields.
+                    #
                     elif bitfield_re.search(param):
                         if dtype != "":  # Skip unnamed bit-fields
                             self.push_parameter(ln, decl_type, bitfield_re.group(1),
-- 
2.50.1
Re: [PATCH 4/7] docs: kdoc: add a couple more comments in create_parameter_list()
Posted by Mauro Carvalho Chehab 1 month, 3 weeks ago
On Tue, 12 Aug 2025 13:57:45 -0600
Jonathan Corbet <corbet@lwn.net> wrote:

> Make what the final code is doing a bit more clear to slow readers like me.
> 
> Signed-off-by: Jonathan Corbet <corbet@lwn.net>

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
>  scripts/lib/kdoc/kdoc_parser.py | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser.py
> index 47f7ea01ed10..36c4035343dc 100644
> --- a/scripts/lib/kdoc/kdoc_parser.py
> +++ b/scripts/lib/kdoc/kdoc_parser.py
> @@ -568,12 +568,18 @@ class KernelDoc:
>  
>                  bitfield_re = KernRe(r'(.*?):(\w+)')
>                  for param in args:
> +                    #
> +                    # For pointers, shift the star(s) from the variable name to the
> +                    # type declaration.
> +                    #
>                      r = KernRe(r'^(\*+)\s*(.*)')
>                      if r.match(param):
>                          self.push_parameter(ln, decl_type, r.group(2),
>                                              f"{dtype} {r.group(1)}",
>                                              arg, declaration_name)
> -
> +                    #
> +                    # Perform a similar shift for bitfields.
> +                    #
>                      elif bitfield_re.search(param):
>                          if dtype != "":  # Skip unnamed bit-fields
>                              self.push_parameter(ln, decl_type, bitfield_re.group(1),



Thanks,
Mauro