Re: [PATCH] scripts: kernel-doc: fix parsing function-like typedefs (again)

From: Jonathan Corbet
Date: Mon Apr 07 2025 - 18:34:41 EST


Sean Anderson <sean.anderson@xxxxxxxxx> writes:

> Typedefs like
>
> typedef struct phylink_pcs *(*pcs_xlate_t)(const u64 *args);
>
> have a typedef_type that ends with a * and therefore has no word
> boundary. Add an extra clause for the final group of the typedef_type so
> we only require a word boundary if we match a word.
>
> Fixes: 7d2c6b1edf79 ("scripts: kernel-doc: fix parsing function-like typedefs")
> Signed-off-by: Sean Anderson <sean.anderson@xxxxxxxxx>
> ---
>
> scripts/kernel-doc | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
> index af6cf408b96d..5db23cbf4eb2 100755
> --- a/scripts/kernel-doc
> +++ b/scripts/kernel-doc
> @@ -1325,7 +1325,7 @@ sub dump_enum($$) {
> }
> }
>
> -my $typedef_type = qr { ((?:\s+[\w\*]+\b){1,8})\s* }x;
> +my $typedef_type = qr { ((?:\s+[\w\*]+\b){0,7}\s+(?:\w+\b|\*+))\s* }x;
> my $typedef_ident = qr { \*?\s*(\w\S+)\s* }x;
> my $typedef_args = qr { \s*\((.*)\); }x;

This seems like a worth fix but ... we're kind of hoping to replace that
script entirely in 6.16.

Mauro, do you have a series for me along those lines? It seems like
time to put that in if we're going to do it. Then maybe this fix could
be adapted on top?

Thanks,

jon