tools: ynl-gen: support local attrs in _multi_parse

The _multi_parse() helper calls the _attr_get() method of each attr,
but it only respects what code the helper wants to emit, not what
local variables it needs. Local variables will soon be needed,
support them.

Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://patch.msgid.link/20250520161916.413298-9-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski 2025-05-20 09:19:12 -07:00
parent a66a170b68
commit 092b34b937

View File

@ -2214,12 +2214,16 @@ def parse_rsp_submsg(ri, struct):
parse_rsp_nested_prototype(ri, struct, suffix='')
var = 'dst'
local_vars = {'const struct nlattr *attr = nested;',
f'{struct.ptr_name}{var} = yarg->data;',
'struct ynl_parse_arg parg;'}
for _, arg in struct.member_list():
_, _, l_vars = arg._attr_get(ri, var)
local_vars |= set(l_vars) if l_vars else set()
ri.cw.block_start()
ri.cw.write_func_lvar(['const struct nlattr *attr = nested;',
f'{struct.ptr_name}{var} = yarg->data;',
'struct ynl_parse_arg parg;'])
ri.cw.write_func_lvar(list(local_vars))
ri.cw.p('parg.ys = yarg->ys;')
ri.cw.nl()