diff mbox series

[net,1/4] ipv6: silence compilation warning for non-IPV6 builds

Message ID 20210202135544.3262383-2-leon@kernel.org
State Awaiting Upstream
Delegated to: Pablo Neira
Headers show
Series Fix W=1 compilation warnings in net/* folder | expand

Commit Message

Leon Romanovsky Feb. 2, 2021, 1:55 p.m. UTC
From: Leon Romanovsky <leonro@nvidia.com>

The W=1 compilation of allmodconfig generates the following warning:

net/ipv6/icmp.c:448:6: warning: no previous prototype for 'icmp6_send' [-Wmissing-prototypes]
  448 | void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
      |      ^~~~~~~~~~

In such configuration, the icmp6_send() is not used outside of icmp.c, so close
its EXPORT_SYMBOL and add "static" word to limit the scope.

Fixes: cc7a21b6fbd9 ("ipv6: icmp6: avoid indirect call for icmpv6_send()")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 net/ipv6/icmp.c | 6 ++++++
 1 file changed, 6 insertions(+)

--
2.29.2

Comments

Jakub Kicinski Feb. 2, 2021, 4:29 p.m. UTC | #1
On Tue,  2 Feb 2021 15:55:41 +0200 Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> The W=1 compilation of allmodconfig generates the following warning:
> 
> net/ipv6/icmp.c:448:6: warning: no previous prototype for 'icmp6_send' [-Wmissing-prototypes]
>   448 | void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
>       |      ^~~~~~~~~~
> 
> In such configuration, the icmp6_send() is not used outside of icmp.c, so close
> its EXPORT_SYMBOL and add "static" word to limit the scope.
> 
> Fixes: cc7a21b6fbd9 ("ipv6: icmp6: avoid indirect call for icmpv6_send()")
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>

That's a little much ifdefinery, why not move the declaration from
under the ifdef in the header instead?

If you repost please target net-next, admittedly these fixes are pretty
"obviously correct" but they are not urgent either.

> diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
> index f3d05866692e..5d4232b492dc 100644
> --- a/net/ipv6/icmp.c
> +++ b/net/ipv6/icmp.c
> @@ -445,6 +445,9 @@ static int icmp6_iif(const struct sk_buff *skb)
>  /*
>   *	Send an ICMP message in response to a packet in error
>   */
> +#if !IS_BUILTIN(CONFIG_IPV6)
> +static
> +#endif
>  void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
>  		const struct in6_addr *force_saddr)
>  {
> @@ -634,7 +637,10 @@ void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
>  out_bh_enable:
>  	local_bh_enable();
>  }
> +
> +#if IS_BUILTIN(CONFIG_IPV6)
>  EXPORT_SYMBOL(icmp6_send);
> +#endif
> 
>  /* Slightly more convenient version of icmp6_send.
>   */
> --
> 2.29.2
>
Leon Romanovsky Feb. 2, 2021, 6:55 p.m. UTC | #2
On Tue, Feb 02, 2021 at 08:29:09AM -0800, Jakub Kicinski wrote:
> On Tue,  2 Feb 2021 15:55:41 +0200 Leon Romanovsky wrote:
> > From: Leon Romanovsky <leonro@nvidia.com>
> >
> > The W=1 compilation of allmodconfig generates the following warning:
> >
> > net/ipv6/icmp.c:448:6: warning: no previous prototype for 'icmp6_send' [-Wmissing-prototypes]
> >   448 | void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
> >       |      ^~~~~~~~~~
> >
> > In such configuration, the icmp6_send() is not used outside of icmp.c, so close
> > its EXPORT_SYMBOL and add "static" word to limit the scope.
> >
> > Fixes: cc7a21b6fbd9 ("ipv6: icmp6: avoid indirect call for icmpv6_send()")
> > Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
>
> That's a little much ifdefinery, why not move the declaration from
> under the ifdef in the header instead?

We will find ourselves with exported but not used function, it will
increase symbol file, not big deal but not nice, either.

>
> If you repost please target net-next, admittedly these fixes are pretty
> "obviously correct" but they are not urgent either.

I'll do.

Thanks
Jakub Kicinski Feb. 2, 2021, 9:55 p.m. UTC | #3
On Tue, 2 Feb 2021 20:55:28 +0200 Leon Romanovsky wrote:
> On Tue, Feb 02, 2021 at 08:29:09AM -0800, Jakub Kicinski wrote:
> > On Tue,  2 Feb 2021 15:55:41 +0200 Leon Romanovsky wrote:  
> > > From: Leon Romanovsky <leonro@nvidia.com>
> > >
> > > The W=1 compilation of allmodconfig generates the following warning:
> > >
> > > net/ipv6/icmp.c:448:6: warning: no previous prototype for 'icmp6_send' [-Wmissing-prototypes]
> > >   448 | void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
> > >       |      ^~~~~~~~~~
> > >
> > > In such configuration, the icmp6_send() is not used outside of icmp.c, so close
> > > its EXPORT_SYMBOL and add "static" word to limit the scope.
> > >
> > > Fixes: cc7a21b6fbd9 ("ipv6: icmp6: avoid indirect call for icmpv6_send()")
> > > Signed-off-by: Leon Romanovsky <leonro@nvidia.com>  
> >
> > That's a little much ifdefinery, why not move the declaration from
> > under the ifdef in the header instead?  
> 
> We will find ourselves with exported but not used function, it will
> increase symbol file, not big deal but not nice, either.

For those all so common builds where IPv6 is a module :)
But I don't feel strongly, up to you.

> > If you repost please target net-next, admittedly these fixes are pretty
> > "obviously correct" but they are not urgent either.  
> 
> I'll do.

Thanks!
diff mbox series

Patch

diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index f3d05866692e..5d4232b492dc 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -445,6 +445,9 @@  static int icmp6_iif(const struct sk_buff *skb)
 /*
  *	Send an ICMP message in response to a packet in error
  */
+#if !IS_BUILTIN(CONFIG_IPV6)
+static
+#endif
 void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
 		const struct in6_addr *force_saddr)
 {
@@ -634,7 +637,10 @@  void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
 out_bh_enable:
 	local_bh_enable();
 }
+
+#if IS_BUILTIN(CONFIG_IPV6)
 EXPORT_SYMBOL(icmp6_send);
+#endif

 /* Slightly more convenient version of icmp6_send.
  */