diff options
| author | Jakub Kicinski <[email protected]> | 2025-05-20 16:19:12 +0000 |
|---|---|---|
| committer | Jakub Kicinski <[email protected]> | 2025-05-21 19:38:22 +0000 |
| commit | 092b34b937353eaa6164ceb1f520b1f640aee54f (patch) | |
| tree | eeff6438613a728b9b2833eb0e6e8d64e156577c /tools/net/ynl/pyynl/ynl_gen_c.py | |
| parent | tools: ynl-gen: move fixed header info from RenderInfo to Struct (diff) | |
| download | kernel-092b34b937353eaa6164ceb1f520b1f640aee54f.tar.gz kernel-092b34b937353eaa6164ceb1f520b1f640aee54f.zip | |
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 <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Diffstat (limited to 'tools/net/ynl/pyynl/ynl_gen_c.py')
| -rwxr-xr-x | tools/net/ynl/pyynl/ynl_gen_c.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py index bd1fadb2cf5a..f2a4404d0d21 100755 --- a/tools/net/ynl/pyynl/ynl_gen_c.py +++ b/tools/net/ynl/pyynl/ynl_gen_c.py @@ -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;'} - 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;']) + 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(list(local_vars)) ri.cw.p('parg.ys = yarg->ys;') ri.cw.nl() |
