From: "Asbjørn Sloth Tønnesen" <ast@fiberby.net>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: "Asbjørn Sloth Tønnesen" <ast@fiberby.net>,
"Donald Hunter" <donald.hunter@gmail.com>,
"Simon Horman" <horms@kernel.org>,
"Jacob Keller" <jacob.e.keller@intel.com>,
"Sabrina Dubroca" <sd@queasysnail.net>,
wireguard@lists.zx2c4.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next v5 07/11] tools: ynl-gen: rename TypeArrayNest to TypeIndexedArray
Date: Mon, 15 Sep 2025 14:42:52 +0000 [thread overview]
Message-ID: <20250915144301.725949-8-ast@fiberby.net> (raw)
In-Reply-To: <20250915144301.725949-1-ast@fiberby.net>
Since TypeArrayNest can now be used with many other sub-types
than nest, then rename it to TypeIndexedArray, to reduce
confusion.
This patch continues the rename, that was started in commit
aa6485d813ad ("ynl: rename array-nest to indexed-array"),
when the YNL type was renamed.
In order to get rid of all references to the old naming,
within ynl, then renaming some variables in _multi_parse().
This is a trivial patch with no behavioural changes intended.
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
---
tools/net/ynl/pyynl/ynl_gen_c.py | 36 ++++++++++++++++----------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
index 9b42e75d24e9..c064e6df41bd 100755
--- a/tools/net/ynl/pyynl/ynl_gen_c.py
+++ b/tools/net/ynl/pyynl/ynl_gen_c.py
@@ -787,7 +787,7 @@ class TypeMultiAttr(Type):
f"{presence} = n_{self.c_name};"]
-class TypeArrayNest(Type):
+class TypeIndexedArray(Type):
def is_multi_val(self):
return True
@@ -824,7 +824,7 @@ class TypeArrayNest(Type):
elif self.attr['sub-type'] == 'nest':
return f'.type = YNL_PT_NEST, .nest = &{self.nested_render_name}_nest, '
else:
- raise Exception(f"Typol for ArrayNest sub-type {self.attr['sub-type']} not supported, yet")
+ raise Exception(f"Typol for IndexedArray sub-type {self.attr['sub-type']} not supported, yet")
def _attr_get(self, ri, var):
local_vars = ['const struct nlattr *attr2;']
@@ -850,7 +850,7 @@ class TypeArrayNest(Type):
ri.cw.p(f'for (i = 0; i < {var}->_count.{self.c_name}; i++)')
ri.cw.p(f"{self.nested_render_name}_put(nlh, i, &{var}->{self.c_name}[i]);")
else:
- raise Exception(f"Put for ArrayNest sub-type {self.attr['sub-type']} not supported, yet")
+ raise Exception(f"Put for IndexedArray sub-type {self.attr['sub-type']} not supported, yet")
ri.cw.p('ynl_attr_nest_end(nlh, array);')
def _setter_lines(self, ri, member, presence):
@@ -1127,7 +1127,7 @@ class AttrSet(SpecAttrSet):
t = TypeNest(self.family, self, elem, value)
elif elem['type'] == 'indexed-array' and 'sub-type' in elem:
if elem["sub-type"] in ['binary', 'nest', 'u32']:
- t = TypeArrayNest(self.family, self, elem, value)
+ t = TypeIndexedArray(self.family, self, elem, value)
else:
raise Exception(f'new_attr: unsupported sub-type {elem["sub-type"]}')
elif elem['type'] == 'nest-type-value':
@@ -2109,18 +2109,18 @@ def _multi_parse(ri, struct, init_lines, local_vars):
else:
raise Exception("Per-op fixed header not supported, yet")
- var_set = set()
- array_nests = set()
+ indexed_arrays = set()
multi_attrs = set()
needs_parg = False
+ var_set = set()
for arg, aspec in struct.member_list():
if aspec['type'] == 'indexed-array' and 'sub-type' in aspec:
if aspec["sub-type"] in {'binary', 'nest'}:
local_vars.append(f'const struct nlattr *attr_{aspec.c_name};')
- array_nests.add(arg)
+ indexed_arrays.add(arg)
elif aspec['sub-type'] in scalars:
local_vars.append(f'const struct nlattr *attr_{aspec.c_name};')
- array_nests.add(arg)
+ indexed_arrays.add(arg)
else:
raise Exception(f'Not supported sub-type {aspec["sub-type"]}')
if 'multi-attr' in aspec:
@@ -2134,16 +2134,16 @@ def _multi_parse(ri, struct, init_lines, local_vars):
except Exception:
pass # _attr_get() not implemented by simple types, ignore
local_vars += list(var_set)
- if array_nests or multi_attrs:
+ if indexed_arrays or multi_attrs:
local_vars.append('int i;')
if needs_parg:
local_vars.append('struct ynl_parse_arg parg;')
init_lines.append('parg.ys = yarg->ys;')
- all_multi = array_nests | multi_attrs
+ all_multi = indexed_arrays | multi_attrs
- for anest in sorted(all_multi):
- local_vars.append(f"unsigned int n_{struct[anest].c_name} = 0;")
+ for arg in sorted(all_multi):
+ local_vars.append(f"unsigned int n_{struct[arg].c_name} = 0;")
ri.cw.block_start()
ri.cw.write_func_lvar(local_vars)
@@ -2163,8 +2163,8 @@ def _multi_parse(ri, struct, init_lines, local_vars):
else:
ri.cw.p('hdr = ynl_nlmsg_data_offset(nlh, sizeof(struct genlmsghdr));')
ri.cw.p(f"memcpy(&dst->_hdr, hdr, sizeof({struct.fixed_header}));")
- for anest in sorted(all_multi):
- aspec = struct[anest]
+ for arg in sorted(all_multi):
+ aspec = struct[arg]
ri.cw.p(f"if (dst->{aspec.c_name})")
ri.cw.p(f'return ynl_error_parse(yarg, "attribute already present ({struct.attr_set.name}.{aspec.name})");')
@@ -2182,8 +2182,8 @@ def _multi_parse(ri, struct, init_lines, local_vars):
ri.cw.block_end()
ri.cw.nl()
- for anest in sorted(array_nests):
- aspec = struct[anest]
+ for arg in sorted(indexed_arrays):
+ aspec = struct[arg]
ri.cw.block_start(line=f"if (n_{aspec.c_name})")
ri.cw.p(f"dst->{aspec.c_name} = calloc(n_{aspec.c_name}, sizeof(*dst->{aspec.c_name}));")
@@ -2208,8 +2208,8 @@ def _multi_parse(ri, struct, init_lines, local_vars):
ri.cw.block_end()
ri.cw.nl()
- for anest in sorted(multi_attrs):
- aspec = struct[anest]
+ for arg in sorted(multi_attrs):
+ aspec = struct[arg]
ri.cw.block_start(line=f"if (n_{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->_count.{aspec.c_name} = n_{aspec.c_name};")
--
2.51.0
next prev parent reply other threads:[~2025-09-15 14:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-15 14:42 [PATCH net-next v5 00/11] tools: ynl: prepare for wireguard Asbjørn Sloth Tønnesen
2025-09-15 14:42 ` [PATCH net-next v5 01/11] tools: ynl-gen: allow overriding name-prefix for constants Asbjørn Sloth Tønnesen
2025-09-15 14:42 ` [PATCH net-next v5 02/11] tools: ynl-gen: generate nested array policies Asbjørn Sloth Tønnesen
2025-09-15 14:42 ` [PATCH net-next v5 03/11] tools: ynl-gen: add sub-type check Asbjørn Sloth Tønnesen
2025-09-15 14:42 ` [PATCH net-next v5 04/11] tools: ynl-gen: refactor local vars for .attr_put() callers Asbjørn Sloth Tønnesen
2025-09-16 1:42 ` Jakub Kicinski
2025-09-15 14:42 ` [PATCH net-next v5 05/11] tools: ynl-gen: avoid repetitive variables definitions Asbjørn Sloth Tønnesen
2025-09-16 1:42 ` Jakub Kicinski
2025-09-15 14:42 ` [PATCH net-next v5 06/11] tools: ynl-gen: validate nested arrays Asbjørn Sloth Tønnesen
2025-09-16 1:42 ` Jakub Kicinski
2025-09-15 14:42 ` Asbjørn Sloth Tønnesen [this message]
2025-09-16 1:43 ` [PATCH net-next v5 07/11] tools: ynl-gen: rename TypeArrayNest to TypeIndexedArray Jakub Kicinski
2025-09-15 14:42 ` [PATCH net-next v5 08/11] tools: ynl: move nest packing to a helper function Asbjørn Sloth Tønnesen
2025-09-15 14:42 ` [PATCH net-next v5 09/11] tools: ynl: encode indexed-arrays Asbjørn Sloth Tønnesen
2025-09-15 14:42 ` [PATCH net-next v5 10/11] tools: ynl: decode hex input Asbjørn Sloth Tønnesen
2025-09-15 14:42 ` [PATCH net-next v5 11/11] tools: ynl: add ipv4-or-v6 display hint Asbjørn Sloth Tønnesen
2025-09-16 15:38 ` [PATCH net-next v5 00/11] tools: ynl: prepare for wireguard patchwork-bot+netdevbpf
2025-09-16 15:53 ` Jason A. Donenfeld
2025-09-16 22:39 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250915144301.725949-8-ast@fiberby.net \
--to=ast@fiberby.net \
--cc=Jason@zx2c4.com \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
--cc=wireguard@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®