diff options
author | Jakub Kicinski <kuba@kernel.org> | 2023-10-25 11:27:39 -0700 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-10-26 19:42:47 -0700 |
commit | eb9df668381d350e462fdf840907388e0a9b80fe (patch) | |
tree | 4db3c026674ba9c17a1a0fb3b021295066d0a4fb /tools/net | |
parent | bc30bb88ff3153fba7693557d15733179adf7492 (diff) |
tools: ynl-gen: respect attr-cnt-name at the attr set level
Davide reports that we look for the attr-cnt-name in the wrong
object. We try to read it from the family, but the schema only
allows for it to exist at attr-set level.
Reported-by: Davide Caratti <dcaratti@redhat.com>
Link: https://lore.kernel.org/all/CAKa-r6vCj+gPEUKpv7AsXqM77N6pB0evuh7myHq=585RA3oD5g@mail.gmail.com/
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Link: https://lore.kernel.org/r/20231025182739.184706-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/net')
-rwxr-xr-x | tools/net/ynl/ynl-gen-c.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py index 1c7474ad92dc..13427436bfb7 100755 --- a/tools/net/ynl/ynl-gen-c.py +++ b/tools/net/ynl/ynl-gen-c.py @@ -789,9 +789,11 @@ class AttrSet(SpecAttrSet): pfx = f"{family.name}-a-{self.name}-" self.name_prefix = c_upper(pfx) self.max_name = c_upper(self.yaml.get('attr-max-name', f"{self.name_prefix}max")) + self.cnt_name = c_upper(self.yaml.get('attr-cnt-name', f"__{self.name_prefix}max")) else: self.name_prefix = family.attr_sets[self.subset_of].name_prefix self.max_name = family.attr_sets[self.subset_of].max_name + self.cnt_name = family.attr_sets[self.subset_of].cnt_name # Added by resolve: self.c_name = None @@ -2354,8 +2356,7 @@ def render_uapi(family, cw): if attr_set.subset_of: continue - cnt_name = c_upper(family.get('attr-cnt-name', f"__{attr_set.name_prefix}MAX")) - max_value = f"({cnt_name} - 1)" + max_value = f"({attr_set.cnt_name} - 1)" val = 0 uapi_enum_start(family, cw, attr_set.yaml, 'enum-name') @@ -2367,7 +2368,7 @@ def render_uapi(family, cw): val += 1 cw.p(attr.enum_name + suffix) cw.nl() - cw.p(cnt_name + ('' if max_by_define else ',')) + cw.p(attr_set.cnt_name + ('' if max_by_define else ',')) if not max_by_define: cw.p(f"{attr_set.max_name} = {max_value}") cw.block_end(line=';') |