net: Mark possible unused variables on stack with __maybe_unused
Subsystems (5)
PATCH 1/1 net: Mark possible unused variables on stack with __maybe_unused
When compile with COMPILE_TEST=y the -Werror is implied. If we run make W=1 the first level warnings will become the build errors. Some of them related to possible unused variables. Hence, to allow clean build in such case, mark them with __maybe_unused.
Signed-off-by Andy Shevchenko <[email protected]>
--- net/ipv4/netfilter/nf_reject_ipv4.c | 2 +- net/ipv6/ip6_fib.c | 3 ++- net/ipv6/netfilter/nf_reject_ipv6.c | 2 +- net/socket.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-)
net/ipv4/netfilter/nf_reject_ipv4.c +1 -1
@@ -239,7 +239,7 @@ void nf_send_reset(struct net *net, struct sock *sk, struct sk_buff *oldskb, {struct net_device *br_indev__maybe_unused ;struct sk_buff *nskb; -struct iphdr *niph; +struct iphdr __maybe_unused *niph;const struct tcphdr *oth;struct tcphdr _oth;
net/ipv6/ip6_fib.c +2 -1
@@ -1374,7 +1374,8 @@ int fib6_add(struct fib6_node *root, struct fib6_info *rt, struct nl_info *info, struct netlink_ext_ack *extack) { struct fib6_table *table = rt->fib6_table; -struct fib6_node *fn, *pn =NULL ; +struct fib6_node *fn; +struct fib6_node __maybe_unused *pn =NULL ;int err = -ENOMEM ;int allow_create =1 ;int replace_required =0 ;
net/ipv6/netfilter/nf_reject_ipv6.c +1 -1
@@ -284,7 +284,7 @@ void nf_send_reset6(struct net *net, struct sock *sk, struct sk_buff *oldskb,const struct tcphdr *otcph;unsigned int otcplen, hh_len;const struct ipv6hdr *oip6h =ipv6_hdr (oldskb); -struct ipv6hdr *ip6h; +struct ipv6hdr __maybe_unused *ip6h;struct dst_entry *dst =NULL ;struct flowi6 fl6;
net/socket.c +1 -1
@@ -2199,7 +2199,7 @@ int __sys_getsockopt(int fd, int level, int optname, char __user *optval, {int err, fput_needed;struct socket *sock; -int max_optlen; +int __maybe_unused max_optlen; sock =sockfd_lookup_light (fd, &err, &fput_needed);if (!sock)
Signature · 1 line
2.33.0
Jakub Kicinski
maintainerQuoted 7 lines · On Fri, 1 Oct 2021 17:50:56 +0300 Andy Shevchenko wrote:
When compile with COMPILE_TEST=y the -Werror is implied. If we run
make W=1the first level warnings will become the build errors. Some of them related to possible unused variables. Hence, to allow clean build in such case, mark them with__maybe_unused.Signed-off-by Andy Shevchenko <[email protected]>
You need to split the socket and fib change from the netfilter ones. Those go via different sub-trees.