Skip to contentSkip to conversation

tools: ynl-gen: use uapi header name for the header guard

PATCH Applied Jakub Kicinski 3 participants 3 messages Oct 3, 2023 – Oct 6, 2023

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 tools: ynl-gen: use uapi header name for the header guard

Chuck points out that we should use the uapi-header property when generating the guard. Otherwise we may generate the same guard as another file in the tree.

---
 tools/net/ynl/ynl-gen-c.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/net/ynl/ynl-gen-c.py +5 -1
index 897af958cee8..168fe612b029 100755
@@ -805,6 +805,10 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
             self.uapi_header = self.yaml['uapi-header']
         else:
             self.uapi_header = f"linux/{self.name}.h"
+        if self.uapi_header.startswith("linux/") and self.uapi_header.endswith('.h'):
+            self.uapi_header_name = self.uapi_header[6:-2]
+        else:
+            self.uapi_header_name = self.name
 
     def resolve(self):
         self.resolve_up(super())
@@ -2124,7 +2128,7 @@ _C_KW = {
 
 
 def render_uapi(family, cw):
-    hdr_prot = f"_UAPI_LINUX_{family.name.upper()}_H"
+    hdr_prot = f"_UAPI_LINUX_{c_upper(family.uapi_header_name)}_H"
     cw.p('#ifndef ' + hdr_prot)
     cw.p('#define ' + hdr_prot)
     cw.nl()
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Jakub Kicinski

Chuck points out that we should use the uapi-header property when generating the guard. Otherwise we may generate the same guard as another file in the tree.

---
  tools/net/ynl/ynl-gen-c.py | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
tools/net/ynl/ynl-gen-c.py +4 -0
index 897af958cee8..168fe612b029 100755
@@ -805,6 +805,10 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
              self.uapi_header = self.yaml['uapi-header']
          else:
              self.uapi_header = f"linux/{self.name}.h"
+        if self.uapi_header.startswith("linux/") and self.uapi_header.endswith('.h'):
+            self.uapi_header_name = self.uapi_header[6:-2]
+        else:
+            self.uapi_header_name = self.name
 
      def resolve(self):
          self.resolve_up(super())

tools/net/ynl/ynl-gen-c.py _C_KW = { · line 2134

Quoted 8 lines
tools/net/ynl/ynl-gen-c.py +1 -1
@@ -2124,7 +2128,7 @@ _C_KW = {
 
 
  def render_uapi(family, cw):
-    hdr_prot = f"_UAPI_LINUX_{family.name.upper()}_H"
+    hdr_prot = f"_UAPI_LINUX_{c_upper(family.uapi_header_name)}_H"
      cw.p('#ifndef ' + hdr_prot)
      cw.p('#define ' + hdr_prot)
      cw.nl()
#2 lore raw
In reply to Jakub Kicinski
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Hello:

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

Quoted 8 lines · On Tue, 3 Oct 2023 15:57:35 -0700 you wrote:

Chuck points out that we should use the uapi-header property when generating the guard. Otherwise we may generate the same guard as another file in the tree.

[...]

Here is the summary with links:
- [net-next] tools: ynl-gen: use uapi header name for the header guard

    https://git.kernel.org/netdev/net-next/c/71ce60d375f5

You are awesome, thank you!

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