lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250813003902.2fc82b54@foz.lan>
Date: Wed, 13 Aug 2025 00:39:02 +0200
From: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
To: Jonathan Corbet <corbet@....net>
Cc: linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org, Akira Yokosawa
 <akiyks@...il.com>
Subject: Re: [PATCH 6/7] docs: kdoc: tighten up the pointer-to-function case

On Tue, 12 Aug 2025 13:57:47 -0600
Jonathan Corbet <corbet@....net> wrote:

> Tighten up the code and remove an unneeded regex operation.
> 
> Signed-off-by: Jonathan Corbet <corbet@....net>
> ---
>  scripts/lib/kdoc/kdoc_parser.py | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser.py
> index d7fb79a64487..ceb38b59fb4c 100644
> --- a/scripts/lib/kdoc/kdoc_parser.py
> +++ b/scripts/lib/kdoc/kdoc_parser.py
> @@ -511,22 +511,19 @@ class KernelDoc:
>                  # Treat preprocessor directive as a typeless variable
>                  self.push_parameter(ln, decl_type, arg, "",
>                                      "", declaration_name)
> -
> +            #
> +            # The pointer-to-function case.
> +            #
>              elif KernRe(r'\(.+\)\s*\(').search(arg):
> -                # Pointer-to-function
> -
>                  arg = arg.replace('#', ',')
> -
> -                r = KernRe(r'[^\(]+\(\*?\s*([\w\[\].]*)\s*\)')
> +                r = KernRe(r'[^\(]+\(\*?\s*' r'([\w\[\].]*)' r'\s*\)')

Heh, it took me a couple of seconds to understand this concat, as I haven't
seem concat pattern like that before (maybe except for some old C book
I read a millennium ago that I barely remember).  So, IMO, it became harder
to understand this way. I would either remove the extra two ' r' from the
string or write it as:

               r = KernRe(r'[^\(]+\(\*?\s*' 
			  r'([\w\[\].]*)'
			  r'\s*\)')

Eventually adding a comment for the capture group. 

With that, feel free to add:

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

>                  if r.match(arg):
>                      param = r.group(1)
>                  else:
>                      self.emit_msg(ln, f"Invalid param: {arg}")
>                      param = arg
> -
> -                dtype = KernRe(r'([^\(]+\(\*?)\s*' + re.escape(param)).sub(r'\1', arg)
> -                self.push_parameter(ln, decl_type, param, dtype,
> -                                    arg, declaration_name)
> +                dtype = arg.replace(param, '')

Nice cleanup. 

> +                self.push_parameter(ln, decl_type, param, dtype, arg, declaration_name)
>              #
>              # The array-of-pointers case.  Dig the parameter name out from the middle
>              # of the declaration.



Thanks,
Mauro

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ