diff mbox series

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

Message ID 20240910083640.1485541-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v3,1/1] netfilter: conntrack: Guard possible unused functions | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 13 of 13 maintainers
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 17 this patch: 17
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 14 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Andy Shevchenko Sept. 10, 2024, 8:35 a.m. UTC
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(-)

Comments

Simon Horman Sept. 10, 2024, 1:21 p.m. UTC | #1
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>
Pablo Neira Ayuso Sept. 15, 2024, 9:14 p.m. UTC | #2
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
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)