]> git.dujemihanovic.xyz Git - linux.git/commit
netfilter: nf_reject: Fix build warning when CONFIG_BRIDGE_NETFILTER=n
authorSimon Horman <horms@kernel.org>
Mon, 16 Sep 2024 09:50:34 +0000 (10:50 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 26 Sep 2024 11:03:02 +0000 (13:03 +0200)
commitfc56878ca1c288e49b5cbb43860a5938e3463654
tree600cb58cfc89d9ae612439d5f97d2fec985dc330
parent642c89c475419b4d0c0d90e29d9c1a0e4351f379
netfilter: nf_reject: Fix build warning when CONFIG_BRIDGE_NETFILTER=n

If CONFIG_BRIDGE_NETFILTER is not enabled, which is the case for x86_64
defconfig, then building nf_reject_ipv4.c and nf_reject_ipv6.c with W=1
using gcc-14 results in the following warnings, which are treated as
errors:

net/ipv4/netfilter/nf_reject_ipv4.c: In function 'nf_send_reset':
net/ipv4/netfilter/nf_reject_ipv4.c:243:23: error: variable 'niph' set but not used [-Werror=unused-but-set-variable]
  243 |         struct iphdr *niph;
      |                       ^~~~
cc1: all warnings being treated as errors
net/ipv6/netfilter/nf_reject_ipv6.c: In function 'nf_send_reset6':
net/ipv6/netfilter/nf_reject_ipv6.c:286:25: error: variable 'ip6h' set but not used [-Werror=unused-but-set-variable]
  286 |         struct ipv6hdr *ip6h;
      |                         ^~~~
cc1: all warnings being treated as errors

Address this by reducing the scope of these local variables to where
they are used, which is code only compiled when CONFIG_BRIDGE_NETFILTER
enabled.

Compile tested and run through netfilter selftests.

Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Closes: https://lore.kernel.org/netfilter-devel/20240906145513.567781-1-andriy.shevchenko@linux.intel.com/
Signed-off-by: Simon Horman <horms@kernel.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/ipv4/netfilter/nf_reject_ipv4.c
net/ipv6/netfilter/nf_reject_ipv6.c