summaryrefslogtreecommitdiff
path: root/tools/net/ynl/ynl-gen-c.py
diff options
context:
space:
mode:
authorDonald Hunter <donald.hunter@gmail.com>2024-03-06 23:10:43 +0000
committerJakub Kicinski <kuba@kernel.org>2024-03-07 20:28:29 -0800
commit6fe7de5e9c08dd6838149a50e468bc8f94e4fdbe (patch)
tree085897cfcfce1561f223ca4259be5d32bd3b5e46 /tools/net/ynl/ynl-gen-c.py
parent771b7012e5f3a49739dab4be60b87517a249a1df (diff)
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>
Diffstat (limited to 'tools/net/ynl/ynl-gen-c.py')
-rwxr-xr-xtools/net/ynl/ynl-gen-c.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 2f5febfe66a1..67bfaff05154 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -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;")