aboutsummaryrefslogtreecommitdiff
path: root/tools/net
diff options
context:
space:
mode:
authorJakub Kicinski2023-06-09 14:43:39 -0700
committerDavid S. Miller2023-06-12 11:01:03 +0100
commitdddc9f53da3e1e359e56edc8da301e145e3b97df (patch)
tree181a21ccc7edbea36bba9f27dc7f07f6c407a64e /tools/net
parentd4813b11d679c80d4c3e20d27dafcd6d3317a69c (diff)
tools: ynl-gen: don't generate enum types if unnamed
If attr set or enum has empty enum name we need to use u32 or int as function arguments and struct members. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/net')
-rwxr-xr-xtools/net/ynl/ynl-gen-c.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 05b49aa459a7..82ee6c7fa22d 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -268,7 +268,8 @@ class TypeScalar(Type):
else:
self.is_bitfield = False
- if 'enum' in self.attr and not self.is_bitfield:
+ maybe_enum = not self.is_bitfield and 'enum' in self.attr
+ if maybe_enum and self.family.consts[self.attr['enum']].enum_name:
self.type_name = f"enum {self.family.name}_{c_lower(self.attr['enum'])}"
else:
self.type_name = '__' + self.type
@@ -652,7 +653,14 @@ class EnumEntry(SpecEnumEntry):
class EnumSet(SpecEnumSet):
def __init__(self, family, yaml):
self.render_name = c_lower(family.name + '-' + yaml['name'])
- self.enum_name = 'enum ' + self.render_name
+
+ if 'enum-name' in yaml:
+ if yaml['enum-name']:
+ self.enum_name = 'enum ' + c_lower(yaml['enum-name'])
+ else:
+ self.enum_name = None
+ else:
+ self.enum_name = 'enum ' + self.render_name
self.value_pfx = yaml.get('name-prefix', f"{family.name}-{yaml['name']}-")