diff mbox series

[net-next,v2,1/1] netfilter: conntrack: Guard possible unused functions

Message ID 20240909154043.1381269-2-andriy.shevchenko@linux.intel.com
State Changes Requested
Headers show
Series [net-next,v2,1/1] netfilter: conntrack: Guard possible unused functions | expand

Commit Message

Andy Shevchenko Sept. 9, 2024, 3:39 p.m. UTC
Some of the functions may be unused, 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>
---
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(-)

Comments

Simon Horman Sept. 9, 2024, 6:35 p.m. UTC | #1
On Mon, Sep 09, 2024 at 06:39:56PM +0300, Andy Shevchenko wrote:
> Some of the functions may be unused, 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.

I think it would be worth mentioning, that
the condition is that neither CONFIG_NETFILTER_NETLINK_GLUE_CT
nor CONFIG_NF_CONNTRACK_EVENTS are defined (enabled).

> 
> 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>
> ---
> 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(-)

...
Andy Shevchenko Sept. 10, 2024, 8:37 a.m. UTC | #2
On Mon, Sep 09, 2024 at 07:35:46PM +0100, Simon Horman wrote:
> On Mon, Sep 09, 2024 at 06:39:56PM +0300, Andy Shevchenko wrote:

...

> > Fix this by guarding possible unused functions with ifdeffery.
> 
> I think it would be worth mentioning, that
> the condition is that neither CONFIG_NETFILTER_NETLINK_GLUE_CT
> nor CONFIG_NF_CONNTRACK_EVENTS are defined (enabled).

Done in v3.
diff mbox series

Patch

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)