Re: [PATCH net-next 01/11] tools: ynl-gen: allow overriding name-prefix for constants

Jacob Keller <[email protected]>
Newsgroups com.zx2c4.lists.wireguard,org.kernel.vger.linux-kernel,org.kernel.vger.netdev
Message-ID <[email protected]>

On 9/4/2025 3:01 PM, Asbjørn Sloth Tønnesen wrote:
> Allow using custom name-prefix with constants,
> just like it is for enum and flags declarations.
> 
> This is needed for generating WG_KEY_LEN in
> include/uapi/linux/wireguard.h from a spec.
> 
> Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
> ---
>  tools/net/ynl/pyynl/ynl_gen_c.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
> index fb7e03805a11..1543d4911bf5 100755
> --- a/tools/net/ynl/pyynl/ynl_gen_c.py
> +++ b/tools/net/ynl/pyynl/ynl_gen_c.py
> @@ -3211,8 +3211,9 @@ def render_uapi(family, cw):
>              cw.block_end(line=';')
>              cw.nl()
>          elif const['type'] == 'const':
> +            name_pfx = const.get('name-prefix', f"{family.ident_name}-")

Previously we always used "{family.ident_name}-", but now we get the
name-prefix and use that, falling back to the default if it doesn't
exist. Good.

Reviewed-by: Jacob Keller <[email protected]>

>              defines.append([c_upper(family.get('c-define-name',
> -                                               f"{family.ident_name}-{const['name']}")),
> +                                               f"{name_pfx}{const['name']}")),
>                              const['value']])
>  
>      if defines:
OpenPGP_signature.asc (application/pgp-signature, 236 B)
-----BEGIN PGP SIGNATURE-----

wnsEABYIACMWIQQgQFSp1zOQVirsQx5qll0+bw8o6AUCaLt9OgUDAAAAAAAKCRBqll0+bw8o6EtO
AP4kRMLoZ9IsZ9gNTJJCmsVfLXG88fr3WBJQ3v85bbvXrQD/ecmtR5X7YggvGUmcPt0nG+fCw8Ud
ECiZxKu9f4gZEgo=
=0Fcv
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.