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@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@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: