Skip to contentSkip to conversation

tools: ynl: use display hints for formatting of scalar attrs

PATCH Applied Jakub Kicinski 3 participants 3 messages Jun 26, 2024 – Jun 27, 2024

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 tools: ynl: use display hints for formatting of scalar attrs

Use display hints for formatting scalar attrs. This is specifically useful for formatting IPv4 addresses carried typically as u32.

---
CC: [email protected]
CC: [email protected]

---
 tools/net/ynl/lib/ynl.py | 2 ++
 1 file changed, 2 insertions(+)
tools/net/ynl/lib/ynl.py +2 -0
index 35e666928119..d42c1d605969 100644
@@ -743,6 +743,8 @@ genl_family_name_to_id = None
                 decoded = attr.as_scalar(attr_spec['type'], attr_spec.byte_order)
                 if 'enum' in attr_spec:
                     decoded = self._decode_enum(decoded, attr_spec)
+                elif attr_spec.display_hint:
+                    decoded = self._formatted_string(decoded, attr_spec.display_hint)
             elif attr_spec["type"] == 'indexed-array':
                 decoded = self._decode_array_attr(attr, attr_spec)
             elif attr_spec["type"] == 'bitfield32':
Signature · 1 line
2.45.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Jakub Kicinski

Use display hints for formatting scalar attrs. This is specifically useful for formatting IPv4 addresses carried typically as u32.

I don't know how scalars got missed out :shrug:

Thanks!

Quoted 20 lines

---
CC: [email protected]
CC: [email protected]

---
 tools/net/ynl/lib/ynl.py | 2 ++
 1 file changed, 2 insertions(+)
tools/net/ynl/lib/ynl.py +2 -0
index 35e666928119..d42c1d605969 100644
@@ -743,6 +743,8 @@ genl_family_name_to_id = None
                 decoded = attr.as_scalar(attr_spec['type'], attr_spec.byte_order)
                 if 'enum' in attr_spec:
                     decoded = self._decode_enum(decoded, attr_spec)
+                elif attr_spec.display_hint:
+                    decoded = self._formatted_string(decoded, attr_spec.display_hint)
             elif attr_spec["type"] == 'indexed-array':
                 decoded = self._decode_array_attr(attr, attr_spec)
             elif attr_spec["type"] == 'bitfield32':
#2 lore raw
In reply to Jakub Kicinski
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 9 lines · On Wed, 26 Jun 2024 13:12:34 -0700 you wrote:

Use display hints for formatting scalar attrs. This is specifically useful for formatting IPv4 addresses carried typically as u32.

---
CC: [email protected]
CC: [email protected]

[...]

Here is the summary with links:
- [net-next] tools: ynl: use display hints for formatting of scalar attrs

    https://git.kernel.org/netdev/net-next/c/2a901623f005

You are awesome, thank you!

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