All of lore.kernel.org
 help / color / mirror / Atom feed
* uapi-header: doesn't update header include guard macros
@ 2023-09-15 16:41 Chuck Lever III
  2023-10-03 21:45 ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: Chuck Lever III @ 2023-09-15 16:41 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: open list:NETWORKING [GENERAL]

Hi Jakub-

This is a minor nit, but I have

name: xxxx
uapi-header: linux/xxxx_netlink.h

in my yaml spec, and the actual uapi file is named

include/uapi/linux/xxxx_netlink.h

but the generated include guard macros in that header still say:

#ifndef _UAPI_LINUX_XXXX_H
#define _UAPI_LINUX_XXXX_H

....

#endif /* _UAPI_LINUX_XXXX_H */

They should use _UAPI_LINUX_XXXX_NETLINK_H instead to avoid
colliding with a human-written include/uapi/linux/xxxx.h.

--
Chuck Lever



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: uapi-header: doesn't update header include guard macros
  2023-09-15 16:41 uapi-header: doesn't update header include guard macros Chuck Lever III
@ 2023-10-03 21:45 ` Jakub Kicinski
  2023-10-03 21:48   ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2023-10-03 21:45 UTC (permalink / raw)
  To: Chuck Lever III; +Cc: open list:NETWORKING [GENERAL]

On Fri, 15 Sep 2023 16:41:59 +0000 Chuck Lever III wrote:
> Hi Jakub-
> 
> This is a minor nit, but I have
> 
> name: xxxx
> uapi-header: linux/xxxx_netlink.h
> 
> in my yaml spec, and the actual uapi file is named
> 
> include/uapi/linux/xxxx_netlink.h
> 
> but the generated include guard macros in that header still say:
> 
> #ifndef _UAPI_LINUX_XXXX_H
> #define _UAPI_LINUX_XXXX_H
> 
> ....
> 
> #endif /* _UAPI_LINUX_XXXX_H */
> 
> They should use _UAPI_LINUX_XXXX_NETLINK_H instead to avoid
> colliding with a human-written include/uapi/linux/xxxx.h.

Fair point, perhaps we can do something like the patch below.
LMK if it's good enough.

We don't have any family of this nature in the networking tree.
Would you need this for 6.7 i.e. the next merge window already?
I can put it on top of an -rc tag when applying, so you can merge..

----->8-----

diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 18532e78e1cf..168fe612b029 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -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.uapi_header}_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()

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: uapi-header: doesn't update header include guard macros
  2023-10-03 21:45 ` Jakub Kicinski
@ 2023-10-03 21:48   ` Jakub Kicinski
  2023-10-03 22:47     ` Chuck Lever III
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2023-10-03 21:48 UTC (permalink / raw)
  To: Chuck Lever III; +Cc: open list:NETWORKING [GENERAL]

On Tue, 3 Oct 2023 14:45:13 -0700 Jakub Kicinski wrote:
> Fair point, perhaps we can do something like the patch below.
> LMK if it's good enough.
> 
> We don't have any family of this nature in the networking tree.
> Would you need this for 6.7 i.e. the next merge window already?
> I can put it on top of an -rc tag when applying, so you can merge..

Sorry I had it half-committed, this should apply more cleanly:

----->8---------

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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 tools/net/ynl/ynl-gen-c.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 897af958cee8..168fe612b029 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -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()
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: uapi-header: doesn't update header include guard macros
  2023-10-03 21:48   ` Jakub Kicinski
@ 2023-10-03 22:47     ` Chuck Lever III
  0 siblings, 0 replies; 4+ messages in thread
From: Chuck Lever III @ 2023-10-03 22:47 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: open list:NETWORKING [GENERAL]



> On Oct 3, 2023, at 5:48 PM, Jakub Kicinski <kuba@kernel.org> wrote:
> 
> On Tue, 3 Oct 2023 14:45:13 -0700 Jakub Kicinski wrote:
>> Fair point, perhaps we can do something like the patch below.
>> LMK if it's good enough.
>> 
>> We don't have any family of this nature in the networking tree.
>> Would you need this for 6.7 i.e. the next merge window already?
>> I can put it on top of an -rc tag when applying, so you can merge..
> 
> Sorry I had it half-committed, this should apply more cleanly:

fwiw -- Tested-by: Chuck Lever <chuck.lever@oracle.com <mailto:chuck.lever@oracle.com>>

I don't see any impending guard name conflicts, so merge this
whenever is convenient for you. Once this is committed, the
next time the nfsd spec changes, include/uapi/linux/nfsd_netlink.h
will get updated.


> ----->8---------
> 
> 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.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> tools/net/ynl/ynl-gen-c.py | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
> index 897af958cee8..168fe612b029 100755
> --- a/tools/net/ynl/ynl-gen-c.py
> +++ b/tools/net/ynl/ynl-gen-c.py
> @@ -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()
> -- 
> 2.41.0
> 
> 

--
Chuck Lever



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-03 22:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-15 16:41 uapi-header: doesn't update header include guard macros Chuck Lever III
2023-10-03 21:45 ` Jakub Kicinski
2023-10-03 21:48   ` Jakub Kicinski
2023-10-03 22:47     ` Chuck Lever III

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.