[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230609214346.1605106-6-kuba@kernel.org>
Date: Fri, 9 Jun 2023 14:43:39 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: davem@...emloft.net
Cc: netdev@...r.kernel.org,
edumazet@...gle.com,
pabeni@...hat.com,
sdf@...gle.com,
Jakub Kicinski <kuba@...nel.org>
Subject: [PATCH net-next 05/12] 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@...nel.org>
---
tools/net/ynl/ynl-gen-c.py | 12 ++++++++++--
1 file 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 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
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 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
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']}-")
--
2.40.1
Powered by blists - more mailing lists