* [linux-next:master 7868/8410] net/netfilter/core.c:353:20: error: unused function 'nf_egress_hook'
@ 2021-10-15 22:12 kernel test robot
2021-10-16 8:13 ` [PATCH nf-next] netfilter: core: Fix clang warnings about unused static inlines Lukas Wunner
0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2021-10-15 22:12 UTC (permalink / raw)
To: Lukas Wunner
Cc: llvm, kbuild-all, Linux Memory Management List, Pablo Neira Ayuso
[-- Attachment #1: Type: text/plain, Size: 2291 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: 7c832d2f9b959e3181370c8b0dacaf9efe13fc05
commit: 42df6e1d221dddc0f2acf2be37e68d553ad65f96 [7868/8410] netfilter: Introduce egress hook
config: x86_64-buildonly-randconfig-r003-20211015 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 6069a6a5049497a32a50a49661c2f4169078bdba)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=42df6e1d221dddc0f2acf2be37e68d553ad65f96
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git fetch --no-tags linux-next master
git checkout 42df6e1d221dddc0f2acf2be37e68d553ad65f96
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
net/netfilter/core.c:344:20: error: unused function 'nf_ingress_hook' [-Werror,-Wunused-function]
static inline bool nf_ingress_hook(const struct nf_hook_ops *reg, int pf)
^
>> net/netfilter/core.c:353:20: error: unused function 'nf_egress_hook' [-Werror,-Wunused-function]
static inline bool nf_egress_hook(const struct nf_hook_ops *reg, int pf)
^
2 errors generated.
vim +/nf_egress_hook +353 net/netfilter/core.c
343
> 344 static inline bool nf_ingress_hook(const struct nf_hook_ops *reg, int pf)
345 {
346 if ((pf == NFPROTO_NETDEV && reg->hooknum == NF_NETDEV_INGRESS) ||
347 (pf == NFPROTO_INET && reg->hooknum == NF_INET_INGRESS))
348 return true;
349
350 return false;
351 }
352
> 353 static inline bool nf_egress_hook(const struct nf_hook_ops *reg, int pf)
354 {
355 return pf == NFPROTO_NETDEV && reg->hooknum == NF_NETDEV_EGRESS;
356 }
357
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 45907 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH nf-next] netfilter: core: Fix clang warnings about unused static inlines
2021-10-15 22:12 [linux-next:master 7868/8410] net/netfilter/core.c:353:20: error: unused function 'nf_egress_hook' kernel test robot
@ 2021-10-16 8:13 ` Lukas Wunner
2021-10-17 13:48 ` Pablo Neira Ayuso
0 siblings, 1 reply; 3+ messages in thread
From: Lukas Wunner @ 2021-10-16 8:13 UTC (permalink / raw)
To: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal
Cc: netfilter-devel, coreteam, llvm, kbuild-all, linux-mm, Nathan Chancellor
Unlike gcc, clang warns about unused static inlines that are not in an
include file:
net/netfilter/core.c:344:20: error: unused function 'nf_ingress_hook' [-Werror,-Wunused-function]
static inline bool nf_ingress_hook(const struct nf_hook_ops *reg, int pf)
^
net/netfilter/core.c:353:20: error: unused function 'nf_egress_hook' [-Werror,-Wunused-function]
static inline bool nf_egress_hook(const struct nf_hook_ops *reg, int pf)
^
According to commit 6863f5643dd7 ("kbuild: allow Clang to find unused
static inline functions for W=1 build"), the proper resolution is to
mark the affected functions as __maybe_unused. An alternative approach
would be to move them to include/linux/netfilter_netdev.h, but since
Pablo didn't do that in commit ddcfa710d40b ("netfilter: add
nf_ingress_hook() helper function"), I'm guessing __maybe_unused is
preferred.
This fixes both the warning introduced by Pablo in v5.10 as well as the
one recently introduced by myself with commit 42df6e1d221d ("netfilter:
Introduce egress hook").
Fixes: ddcfa710d40b ("netfilter: add nf_ingress_hook() helper function")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: stable@vger.kernel.org # v5.10+
---
net/netfilter/core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index 3a32a813fcde..6dec9cd395f1 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -341,7 +341,8 @@ static int nf_ingress_check(struct net *net, const struct nf_hook_ops *reg,
return 0;
}
-static inline bool nf_ingress_hook(const struct nf_hook_ops *reg, int pf)
+static inline bool __maybe_unused nf_ingress_hook(const struct nf_hook_ops *reg,
+ int pf)
{
if ((pf == NFPROTO_NETDEV && reg->hooknum == NF_NETDEV_INGRESS) ||
(pf == NFPROTO_INET && reg->hooknum == NF_INET_INGRESS))
@@ -350,7 +351,8 @@ static inline bool nf_ingress_hook(const struct nf_hook_ops *reg, int pf)
return false;
}
-static inline bool nf_egress_hook(const struct nf_hook_ops *reg, int pf)
+static inline bool __maybe_unused nf_egress_hook(const struct nf_hook_ops *reg,
+ int pf)
{
return pf == NFPROTO_NETDEV && reg->hooknum == NF_NETDEV_EGRESS;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH nf-next] netfilter: core: Fix clang warnings about unused static inlines
2021-10-16 8:13 ` [PATCH nf-next] netfilter: core: Fix clang warnings about unused static inlines Lukas Wunner
@ 2021-10-17 13:48 ` Pablo Neira Ayuso
0 siblings, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2021-10-17 13:48 UTC (permalink / raw)
To: Lukas Wunner
Cc: Jozsef Kadlecsik, Florian Westphal, netfilter-devel, coreteam,
llvm, kbuild-all, linux-mm, Nathan Chancellor
On Sat, Oct 16, 2021 at 10:13:27AM +0200, Lukas Wunner wrote:
> Unlike gcc, clang warns about unused static inlines that are not in an
> include file:
>
> net/netfilter/core.c:344:20: error: unused function 'nf_ingress_hook' [-Werror,-Wunused-function]
> static inline bool nf_ingress_hook(const struct nf_hook_ops *reg, int pf)
> ^
> net/netfilter/core.c:353:20: error: unused function 'nf_egress_hook' [-Werror,-Wunused-function]
> static inline bool nf_egress_hook(const struct nf_hook_ops *reg, int pf)
> ^
>
> According to commit 6863f5643dd7 ("kbuild: allow Clang to find unused
> static inline functions for W=1 build"), the proper resolution is to
> mark the affected functions as __maybe_unused. An alternative approach
> would be to move them to include/linux/netfilter_netdev.h, but since
> Pablo didn't do that in commit ddcfa710d40b ("netfilter: add
> nf_ingress_hook() helper function"), I'm guessing __maybe_unused is
> preferred.
>
> This fixes both the warning introduced by Pablo in v5.10 as well as the
> one recently introduced by myself with commit 42df6e1d221d ("netfilter:
> Introduce egress hook").
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-10-17 13:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15 22:12 [linux-next:master 7868/8410] net/netfilter/core.c:353:20: error: unused function 'nf_egress_hook' kernel test robot
2021-10-16 8:13 ` [PATCH nf-next] netfilter: core: Fix clang warnings about unused static inlines Lukas Wunner
2021-10-17 13:48 ` 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).