Re: [PATCH 06/12] docs: kdoc: split struct-member rewriting out of dump_struct()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Em Thu, 31 Jul 2025 18:13:20 -0600
Jonathan Corbet <corbet@xxxxxxx> escreveu:

> The massive loop that massages struct members shares no data with the rest
> of dump_struct(); split it out into its own function.  Code movement only,
> no other changes.
> 
> Signed-off-by: Jonathan Corbet <corbet@xxxxxxx>

LGTM.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx>

> ---
>  scripts/lib/kdoc/kdoc_parser.py | 65 +++++++++++++++++----------------
>  1 file changed, 34 insertions(+), 31 deletions(-)
> 
> diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser.py
> index 2bb0da22048f..5c4ad8febb9f 100644
> --- a/scripts/lib/kdoc/kdoc_parser.py
> +++ b/scripts/lib/kdoc/kdoc_parser.py
> @@ -647,37 +647,7 @@ class KernelDoc:
>                  return (r.group(1), r.group(3), r.group(2))
>          return None
>  
> -    def dump_struct(self, ln, proto):
> -        """
> -        Store an entry for an struct or union
> -        """
> -        #
> -        # Do the basic parse to get the pieces of the declaration.
> -        #
> -        struct_parts = self.split_struct_proto(proto)
> -        if not struct_parts:
> -            self.emit_msg(ln, f"{proto} error: Cannot parse struct or union!")
> -            return
> -        decl_type, declaration_name, members = struct_parts
> -
> -        if self.entry.identifier != declaration_name:
> -            self.emit_msg(ln, f"expecting prototype for {decl_type} {self.entry.identifier}. "
> -                          f"Prototype was for {decl_type} {declaration_name} instead\n")
> -            return
> -        #
> -        # Go through the list of members applying all of our transformations.
> -        #
> -        members = trim_private_members(members)
> -        for search, sub in struct_prefixes:
> -            members = search.sub(sub, members)
> -
> -        nested = NestedMatch()
> -        for search, sub in struct_nested_prefixes:
> -            members = nested.sub(search, sub, members)
> -
> -        # Keeps the original declaration as-is
> -        declaration = members
> -
> +    def rewrite_struct_members(self, members):
>          # Split nested struct/union elements
>          #
>          # This loop was simpler at the original kernel-doc perl version, as
> @@ -768,6 +738,39 @@ class KernelDoc:
>                                      newmember += f"{dtype} {s_id}.{name}; "
>  
>                  members = members.replace(oldmember, newmember)
> +        return members
> +
> +    def dump_struct(self, ln, proto):
> +        """
> +        Store an entry for an struct or union
> +        """
> +        #
> +        # Do the basic parse to get the pieces of the declaration.
> +        #
> +        struct_parts = self.split_struct_proto(proto)
> +        if not struct_parts:
> +            self.emit_msg(ln, f"{proto} error: Cannot parse struct or union!")
> +            return
> +        decl_type, declaration_name, members = struct_parts
> +
> +        if self.entry.identifier != declaration_name:
> +            self.emit_msg(ln, f"expecting prototype for {decl_type} {self.entry.identifier}. "
> +                          f"Prototype was for {decl_type} {declaration_name} instead\n")
> +            return
> +        #
> +        # Go through the list of members applying all of our transformations.
> +        #
> +        members = trim_private_members(members)
> +        for search, sub in struct_prefixes:
> +            members = search.sub(sub, members)
> +
> +        nested = NestedMatch()
> +        for search, sub in struct_nested_prefixes:
> +            members = nested.sub(search, sub, members)
> +
> +        # Keeps the original declaration as-is
> +        declaration = members
> +        members = self.rewrite_struct_members(members)
>  
>          # Ignore other nested elements, like enums
>          members = re.sub(r'(\{[^\{\}]*\})', '', members)



Thanks,
Mauro




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux