mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 23:22:31 +02:00
tools: ynl-gen: rename TypeArrayNest to TypeIndexedArray
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
aa6485d813 ("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>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20250915144301.725949-8-ast@fiberby.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
1d99aa4ed7
commit
a44a93ea6f
|
|
@ -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} = NULL;')
|
||||
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} = NULL;')
|
||||
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};")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user