Skip to contentSkip to conversation

tools: ynl: fix setting presence bits in simple nests

PATCH Applied Jakub Kicinski 3 participants 3 messages Mar 21, 2024 – Mar 23, 2024

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 tools: ynl: fix setting presence bits in simple nests

When we set members of simple nested structures in requests we need to set "presence" bits for all the nesting layers below. This has nothing to do with the presence type of the last layer.

Fixes be5bea1cc0bf ("net: add basic C code generators for Netlink")

---
CC: [email protected]

---
 tools/net/ynl/ynl-gen-c.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
tools/net/ynl/ynl-gen-c.py +5 -2
index 6b7eb2d2aaf1..a451cbfbd781 100755
@@ -228,8 +228,11 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
         presence = ''
         for i in range(0, len(ref)):
             presence = f"{var}->{'.'.join(ref[:i] + [''])}_present.{ref[i]}"
-            if self.presence_type() == 'bit':
-                code.append(presence + ' = 1;')
+            # Every layer below last is a nest, so we know it uses bit presence
+            # last layer is "self" and may be a complex type
+            if i == len(ref) - 1 and self.presence_type() != 'bit':
+                continue
+            code.append(presence + ' = 1;')
         code += self._setter_lines(ri, member, presence)
 
         func_name = f"{op_prefix(ri, direction, deref=deref)}_set_{'_'.join(ref)}"
Signature · 1 line
2.44.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Jakub Kicinski

When we set members of simple nested structures in requests we need to set "presence" bits for all the nesting layers below. This has nothing to do with the presence type of the last layer.

Fixes be5bea1cc0bf ("net: add basic C code generators for Netlink")
#2 lore raw
In reply to Jakub Kicinski
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Wed, 20 Mar 2024 19:02:14 -0700 you wrote:

When we set members of simple nested structures in requests we need to set "presence" bits for all the nesting layers below. This has nothing to do with the presence type of the last layer.

Fixes be5bea1cc0bf ("net: add basic C code generators for Netlink")

[...]

Here is the summary with links:
- [net] tools: ynl: fix setting presence bits in simple nests

    https://git.kernel.org/netdev/net/c/f6c8f5e8694c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html