Re: [PATCH net-next 04/11] tools: ynl-gen: define count iterator in print_dump()

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:
> In wireguard_get_device_dump(), as generated by print_dump(),
> it didn't generate a declaration of `unsigned int i`:
> 
> $ make -C tools/net/ynl/generated wireguard-user.o
> -e      CC wireguard-user.o
> wireguard-user.c: In function ‘wireguard_get_device_dump’:
> wireguard-user.c:502:22: error: ‘i’ undeclared (first use in this fn)
>   502 |                 for (i = 0; i < req->_count.peers; i++)
>       |                      ^
> 
> Copy the logic from print_req() as it correctly generated the
> iterator in wireguard_set_device().
> 
> Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
> ---

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

>  tools/net/ynl/pyynl/ynl_gen_c.py | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
> index 04c26ed92ca3..b0eeedfca2f2 100755
> --- a/tools/net/ynl/pyynl/ynl_gen_c.py
> +++ b/tools/net/ynl/pyynl/ynl_gen_c.py
> @@ -2425,6 +2425,11 @@ def print_dump(ri):
>          local_vars += ['size_t hdr_len;',
>                         'void *hdr;']
>  
> +    for _, attr in ri.struct['request'].member_list():
> +        if attr.presence_type() == 'count':
> +            local_vars += ['unsigned int i;']
> +            break
> +
>      ri.cw.write_func_lvar(local_vars)
>  
>      ri.cw.p('yds.yarg.ys = ys;')
OpenPGP_signature.asc (application/pgp-signature, 236 B)
-----BEGIN PGP SIGNATURE-----

wnsEABYIACMWIQQgQFSp1zOQVirsQx5qll0+bw8o6AUCaLt+agUDAAAAAAAKCRBqll0+bw8o6B+n
AP4gWchHRGG9E0hn5WRiAT14gew9/yElqGTRNSMaWkVmKQD+J5HaF7FJ2BnPKurqLf41dkxVI0MI
iQlFQ+ASUPRW9gA=
=TA1h
-----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.