* [PATCH net-next] tools: ynl-gen: use enum name from the spec
@ 2023-11-23 3:10 Jakub Kicinski
2023-11-24 15:30 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Kicinski @ 2023-11-23 3:10 UTC (permalink / raw)
To: davem; +Cc: netdev, edumazet, pabeni, Jakub Kicinski
The enum name used for id-to-str table does not handle
the enum-name override in the spec correctly.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
tools/net/ynl/ynl-gen-c.py | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 88a1e50e6ba8..b891044ecb14 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -755,11 +755,17 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
if 'enum-name' in yaml:
if yaml['enum-name']:
self.enum_name = 'enum ' + c_lower(yaml['enum-name'])
+ self.user_type = self.enum_name
else:
self.enum_name = None
else:
self.enum_name = 'enum ' + self.render_name
+ if self.enum_name:
+ self.user_type = self.enum_name
+ else:
+ self.user_type = 'int'
+
self.value_pfx = yaml.get('name-prefix', f"{family.name}-{yaml['name']}-")
super().__init__(family, yaml)
@@ -1483,8 +1489,8 @@ _C_KW = {
def _put_enum_to_str_helper(cw, render_name, map_name, arg_name, enum=None):
args = [f'int {arg_name}']
- if enum and not ('enum-name' in enum and not enum['enum-name']):
- args = [f'enum {render_name} {arg_name}']
+ if enum:
+ args = [enum.user_type + ' ' + arg_name]
cw.write_func_prot('const char *', f'{render_name}_str', args)
cw.block_start()
if enum and enum.type == 'flags':
@@ -1516,9 +1522,7 @@ _C_KW = {
def put_enum_to_str_fwd(family, cw, enum):
- args = [f'enum {enum.render_name} value']
- if 'enum-name' in enum and not enum['enum-name']:
- args = ['int value']
+ args = [enum.user_type + ' value']
cw.write_func_prot('const char *', f'{enum.render_name}_str', args, suffix=';')
--
2.42.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] tools: ynl-gen: use enum name from the spec
2023-11-23 3:10 [PATCH net-next] tools: ynl-gen: use enum name from the spec Jakub Kicinski
@ 2023-11-24 15:30 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-11-24 15:30 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni
Hello:
This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:
On Wed, 22 Nov 2023 19:10:50 -0800 you wrote:
> The enum name used for id-to-str table does not handle
> the enum-name override in the spec correctly.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> tools/net/ynl/ynl-gen-c.py | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
Here is the summary with links:
- [net-next] tools: ynl-gen: use enum name from the spec
https://git.kernel.org/netdev/net-next/c/30c902001534
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-24 15:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-23 3:10 [PATCH net-next] tools: ynl-gen: use enum name from the spec Jakub Kicinski
2023-11-24 15:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).