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

Jacob Keller jacob.e.keller at intel.com
Sat Sep 6 00:15:54 UTC 2025



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 <ast at fiberby.net>
> ---
>  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 <jacob.e.keller at intel.com>

>              defines.append([c_upper(family.get('c-define-name',
> -                                               f"{family.ident_name}-{const['name']}")),
> +                                               f"{name_pfx}{const['name']}")),
>                              const['value']])
>  
>      if defines:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 236 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/wireguard/attachments/20250905/eacb1e69/attachment.sig>


More information about the WireGuard mailing list