mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 10:33:41 +02:00
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 <donald.hunter@gmail.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Link: https://patch.msgid.link/20250429154704.2613851-3-kuba@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
a6471da774
commit
2286905f1b
|
|
@ -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=''):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user