mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-04 01:24:12 +08:00
tools/net/ynl: Fix c codegen for array-nest
ynl-gen-c generates e.g. 'calloc(mcast_groups, sizeof(*dst->mcast_groups))' for array-nest attrs when it should be 'n_mcast_groups'. Add a 'n_' prefix in the generated code for array-nests. Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Link: https://lore.kernel.org/r/20240306231046.97158-4-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
771b7012e5
commit
6fe7de5e9c
@ -1667,7 +1667,7 @@ def _multi_parse(ri, struct, init_lines, local_vars):
|
||||
aspec = struct[anest]
|
||||
|
||||
ri.cw.block_start(line=f"if (n_{aspec.c_name})")
|
||||
ri.cw.p(f"dst->{aspec.c_name} = calloc({aspec.c_name}, sizeof(*dst->{aspec.c_name}));")
|
||||
ri.cw.p(f"dst->{aspec.c_name} = calloc(n_{aspec.c_name}, sizeof(*dst->{aspec.c_name}));")
|
||||
ri.cw.p(f"dst->n_{aspec.c_name} = n_{aspec.c_name};")
|
||||
ri.cw.p('i = 0;')
|
||||
ri.cw.p(f"parg.rsp_policy = &{aspec.nested_render_name}_nest;")
|
||||
|
Loading…
Reference in New Issue
Block a user