netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v3 1/1] netfilter: conntrack: Guard possible unused functions
@ 2024-09-10  8:35 Andy Shevchenko
  2024-09-10 13:21 ` Simon Horman
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2024-09-10  8:35 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Felix Huettner, netfilter-devel, coreteam,
	netdev, linux-kernel, llvm
  Cc: Jozsef Kadlecsik, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Andy Shevchenko

Some of the functions may be unused (CONFIG_NETFILTER_NETLINK_GLUE_CT=n
and CONFIG_NF_CONNTRACK_EVENTS=n), it prevents kernel builds with clang,
`make W=1` and CONFIG_WERROR=y:

net/netfilter/nf_conntrack_netlink.c:657:22: error: unused function 'ctnetlink_acct_size' [-Werror,-Wunused-function]
  657 | static inline size_t ctnetlink_acct_size(const struct nf_conn *ct)
      |                      ^~~~~~~~~~~~~~~~~~~
net/netfilter/nf_conntrack_netlink.c:667:19: error: unused function 'ctnetlink_secctx_size' [-Werror,-Wunused-function]
  667 | static inline int ctnetlink_secctx_size(const struct nf_conn *ct)
      |                   ^~~~~~~~~~~~~~~~~~~~~
net/netfilter/nf_conntrack_netlink.c:683:22: error: unused function 'ctnetlink_timestamp_size' [-Werror,-Wunused-function]
  683 | static inline size_t ctnetlink_timestamp_size(const struct nf_conn *ct)
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~

Fix this by guarding possible unused functions with ifdeffery.

See also commit 6863f5643dd7 ("kbuild: allow Clang to find unused static
inline functions for W=1 build").

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---

v3: explicitly mentioned the configuration options that lead to issue (Simon)
v2: fixed typo, dropped Fixes (Simon), optimised by reusing existing ifdeffery

 net/netfilter/nf_conntrack_netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 4cbf71d0786b..39430f333f05 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -652,7 +652,6 @@ static size_t ctnetlink_proto_size(const struct nf_conn *ct)
 
 	return len + len4;
 }
-#endif
 
 static inline size_t ctnetlink_acct_size(const struct nf_conn *ct)
 {
@@ -690,6 +689,7 @@ static inline size_t ctnetlink_timestamp_size(const struct nf_conn *ct)
 	return 0;
 #endif
 }
+#endif
 
 #ifdef CONFIG_NF_CONNTRACK_EVENTS
 static size_t ctnetlink_nlmsg_size(const struct nf_conn *ct)
-- 
2.43.0.rc1.1336.g36b5255a03ac


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

* Re: [PATCH net-next v3 1/1] netfilter: conntrack: Guard possible unused functions
  2024-09-10  8:35 [PATCH net-next v3 1/1] netfilter: conntrack: Guard possible unused functions Andy Shevchenko
@ 2024-09-10 13:21 ` Simon Horman
  2024-09-15 21:14   ` Pablo Neira Ayuso
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Horman @ 2024-09-10 13:21 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Pablo Neira Ayuso, Felix Huettner, netfilter-devel, coreteam,
	netdev, linux-kernel, llvm, Jozsef Kadlecsik, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt

On Tue, Sep 10, 2024 at 11:35:33AM +0300, Andy Shevchenko wrote:
> Some of the functions may be unused (CONFIG_NETFILTER_NETLINK_GLUE_CT=n
> and CONFIG_NF_CONNTRACK_EVENTS=n), it prevents kernel builds with clang,
> `make W=1` and CONFIG_WERROR=y:
> 
> net/netfilter/nf_conntrack_netlink.c:657:22: error: unused function 'ctnetlink_acct_size' [-Werror,-Wunused-function]
>   657 | static inline size_t ctnetlink_acct_size(const struct nf_conn *ct)
>       |                      ^~~~~~~~~~~~~~~~~~~
> net/netfilter/nf_conntrack_netlink.c:667:19: error: unused function 'ctnetlink_secctx_size' [-Werror,-Wunused-function]
>   667 | static inline int ctnetlink_secctx_size(const struct nf_conn *ct)
>       |                   ^~~~~~~~~~~~~~~~~~~~~
> net/netfilter/nf_conntrack_netlink.c:683:22: error: unused function 'ctnetlink_timestamp_size' [-Werror,-Wunused-function]
>   683 | static inline size_t ctnetlink_timestamp_size(const struct nf_conn *ct)
>       |                      ^~~~~~~~~~~~~~~~~~~~~~~~
> 
> Fix this by guarding possible unused functions with ifdeffery.
> 
> See also commit 6863f5643dd7 ("kbuild: allow Clang to find unused static
> inline functions for W=1 build").
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> 
> v3: explicitly mentioned the configuration options that lead to issue (Simon)
> v2: fixed typo, dropped Fixes (Simon), optimised by reusing existing ifdeffery

Thanks for the updates.

Reviewed-by: Simon Horman <horms@kernel.org>

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

* Re: [PATCH net-next v3 1/1] netfilter: conntrack: Guard possible unused functions
  2024-09-10 13:21 ` Simon Horman
@ 2024-09-15 21:14   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2024-09-15 21:14 UTC (permalink / raw)
  To: Simon Horman
  Cc: Andy Shevchenko, Felix Huettner, netfilter-devel, coreteam,
	netdev, linux-kernel, llvm, Jozsef Kadlecsik, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt

On Tue, Sep 10, 2024 at 02:21:01PM +0100, Simon Horman wrote:
> On Tue, Sep 10, 2024 at 11:35:33AM +0300, Andy Shevchenko wrote:
> > Some of the functions may be unused (CONFIG_NETFILTER_NETLINK_GLUE_CT=n
> > and CONFIG_NF_CONNTRACK_EVENTS=n), it prevents kernel builds with clang,
> > `make W=1` and CONFIG_WERROR=y:
> > 
> > net/netfilter/nf_conntrack_netlink.c:657:22: error: unused function 'ctnetlink_acct_size' [-Werror,-Wunused-function]
> >   657 | static inline size_t ctnetlink_acct_size(const struct nf_conn *ct)
> >       |                      ^~~~~~~~~~~~~~~~~~~
> > net/netfilter/nf_conntrack_netlink.c:667:19: error: unused function 'ctnetlink_secctx_size' [-Werror,-Wunused-function]
> >   667 | static inline int ctnetlink_secctx_size(const struct nf_conn *ct)
> >       |                   ^~~~~~~~~~~~~~~~~~~~~
> > net/netfilter/nf_conntrack_netlink.c:683:22: error: unused function 'ctnetlink_timestamp_size' [-Werror,-Wunused-function]
> >   683 | static inline size_t ctnetlink_timestamp_size(const struct nf_conn *ct)
> >       |                      ^~~~~~~~~~~~~~~~~~~~~~~~
> > 
> > Fix this by guarding possible unused functions with ifdeffery.
> > 
> > See also commit 6863f5643dd7 ("kbuild: allow Clang to find unused static
> > inline functions for W=1 build").
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> > 
> > v3: explicitly mentioned the configuration options that lead to issue (Simon)
> > v2: fixed typo, dropped Fixes (Simon), optimised by reusing existing ifdeffery
> 
> Thanks for the updates.
> 
> Reviewed-by: Simon Horman <horms@kernel.org>

Applied to nf.git

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

end of thread, other threads:[~2024-09-15 21:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-10  8:35 [PATCH net-next v3 1/1] netfilter: conntrack: Guard possible unused functions Andy Shevchenko
2024-09-10 13:21 ` Simon Horman
2024-09-15 21:14   ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).