aboutsummaryrefslogtreecommitdiffstats
path: root/tools/net/ynl
diff options
context:
space:
mode:
authorJakub Kicinski <[email protected]>2025-04-29 15:46:54 +0000
committerPaolo Abeni <[email protected]>2025-05-02 10:41:02 +0000
commit2286905f1b33cafa25e508f20bfceb47e20e85d8 (patch)
tree38a0d6409a8f3829fed0a215410cea35c6c44381 /tools/net/ynl
parenttools: ynl-gen: fix comment about nested struct dict (diff)
downloadkernel-2286905f1b33cafa25e508f20bfceb47e20e85d8.tar.gz
kernel-2286905f1b33cafa25e508f20bfceb47e20e85d8.zip
tools: ynl-gen: factor out free_needs_iter for a struct
Instead of walking the entries in the code gen add a method for the struct class to return if any of the members need an iterator. Reviewed-by: Donald Hunter <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
Diffstat (limited to 'tools/net/ynl')
-rwxr-xr-xtools/net/ynl/pyynl/ynl_gen_c.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
index 077aacd5f33a..90f7fe6b623b 100755
--- a/tools/net/ynl/pyynl/ynl_gen_c.py
+++ b/tools/net/ynl/pyynl/ynl_gen_c.py
@@ -809,6 +809,12 @@ class Struct:
raise Exception("Inheriting different members not supported")
self.inherited = [c_lower(x) for x in sorted(self._inherited)]
+ def free_needs_iter(self):
+ for _, attr in self.attr_list:
+ if attr.free_needs_iter():
+ return True
+ return False
+
class EnumEntry(SpecEnumEntry):
def __init__(self, enum_set, yaml, prev, value_start):
@@ -2156,11 +2162,9 @@ def print_wrapped_type(ri):
def _free_type_members_iter(ri, struct):
- for _, attr in struct.member_list():
- if attr.free_needs_iter():
- ri.cw.p('unsigned int i;')
- ri.cw.nl()
- break
+ if struct.free_needs_iter():
+ ri.cw.p('unsigned int i;')
+ ri.cw.nl()
def _free_type_members(ri, var, struct, ref=''):