Commit 7cf93538 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

tools: ynl: fully inherit attrs in subsets

To avoid having to repeat the entire definition of an attribute
(including the value) use the Attr object from the original set.
In fact this is already the documented expectation.

Fixes: be5bea1c ("net: add basic C code generators for Netlink")
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ad93bab6
...@@ -199,7 +199,8 @@ The ``value`` property can be skipped, in which case the attribute ID ...@@ -199,7 +199,8 @@ The ``value`` property can be skipped, in which case the attribute ID
will be the value of the previous attribute plus one (recursively) will be the value of the previous attribute plus one (recursively)
and ``0`` for the first attribute in the attribute set. and ``0`` for the first attribute in the attribute set.
Note that the ``value`` of an attribute is defined only in its main set. Note that the ``value`` of an attribute is defined only in its main set
(not in subsets).
enum enum
~~~~ ~~~~
......
...@@ -95,6 +95,7 @@ class SpecAttrSet(SpecElement): ...@@ -95,6 +95,7 @@ class SpecAttrSet(SpecElement):
self.attrs = collections.OrderedDict() self.attrs = collections.OrderedDict()
self.attrs_by_val = collections.OrderedDict() self.attrs_by_val = collections.OrderedDict()
if self.subset_of is None:
val = 0 val = 0
for elem in self.yaml['attributes']: for elem in self.yaml['attributes']:
if 'value' in elem: if 'value' in elem:
...@@ -104,6 +105,12 @@ class SpecAttrSet(SpecElement): ...@@ -104,6 +105,12 @@ class SpecAttrSet(SpecElement):
self.attrs[attr.name] = attr self.attrs[attr.name] = attr
self.attrs_by_val[attr.value] = attr self.attrs_by_val[attr.value] = attr
val += 1 val += 1
else:
real_set = family.attr_sets[self.subset_of]
for elem in self.yaml['attributes']:
attr = real_set[elem['name']]
self.attrs[attr.name] = attr
self.attrs_by_val[attr.value] = attr
def new_attr(self, elem, value): def new_attr(self, elem, value):
return SpecAttr(self.family, self, elem, value) return SpecAttr(self.family, self, elem, value)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment