Thread (55 messages) 55 messages, 6 authors, 2025-09-11
STALE294d
Revisions (5)
  1. v1 current
  2. v2 [diff vs current]
  3. v3 [diff vs current]
  4. v4 [diff vs current]
  5. v5 [diff vs current]

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

From: Asbjørn Sloth Tønnesen <hidden>
Date: 2025-09-04 22:03:33
Also in: lkml
Subsystem: networking [general], the rest, yaml netlink (ynl) · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds, Donald Hunter

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 <redacted>
---
 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;')
-- 
2.51.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help