netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/core/filter: fix unused-variable warning
@ 2018-09-07 12:50 Anders Roxell
  2018-09-11 22:13 ` Alexei Starovoitov
  0 siblings, 1 reply; 2+ messages in thread
From: Anders Roxell @ 2018-09-07 12:50 UTC (permalink / raw)
  To: davem, ast, daniel, tehnerd; +Cc: netdev, linux-kernel, Anders Roxell

Building with CONFIG_INET=n will show the warning below:
net/core/filter.c: In function ‘____bpf_getsockopt’:
net/core/filter.c:4048:19: warning: unused variable ‘tp’ [-Wunused-variable]
  struct tcp_sock *tp;
                   ^~
net/core/filter.c:4046:31: warning: unused variable ‘icsk’ [-Wunused-variable]
  struct inet_connection_sock *icsk;
                               ^~~~
Move the variable declarations inside the {} block where they are used.

Fixes: 1e215300f138 ("bpf: add TCP_SAVE_SYN/TCP_SAVED_SYN options for bpf_(set|get)sockopt")
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
 net/core/filter.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index d301134bca3a..0ae7185b2207 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4043,14 +4043,14 @@ static const struct bpf_func_proto bpf_setsockopt_proto = {
 BPF_CALL_5(bpf_getsockopt, struct bpf_sock_ops_kern *, bpf_sock,
 	   int, level, int, optname, char *, optval, int, optlen)
 {
-	struct inet_connection_sock *icsk;
 	struct sock *sk = bpf_sock->sk;
-	struct tcp_sock *tp;
 
 	if (!sk_fullsock(sk))
 		goto err_clear;
 #ifdef CONFIG_INET
 	if (level == SOL_TCP && sk->sk_prot->getsockopt == tcp_getsockopt) {
+		struct inet_connection_sock *icsk;
+		struct tcp_sock *tp;
 		switch (optname) {
 		case TCP_CONGESTION:
 			icsk = inet_csk(sk);
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net/core/filter: fix unused-variable warning
  2018-09-07 12:50 [PATCH] net/core/filter: fix unused-variable warning Anders Roxell
@ 2018-09-11 22:13 ` Alexei Starovoitov
  0 siblings, 0 replies; 2+ messages in thread
From: Alexei Starovoitov @ 2018-09-11 22:13 UTC (permalink / raw)
  To: Anders Roxell; +Cc: davem, ast, daniel, tehnerd, netdev, linux-kernel

On Fri, Sep 07, 2018 at 02:50:05PM +0200, Anders Roxell wrote:
> Building with CONFIG_INET=n will show the warning below:
> net/core/filter.c: In function ‘____bpf_getsockopt’:
> net/core/filter.c:4048:19: warning: unused variable ‘tp’ [-Wunused-variable]
>   struct tcp_sock *tp;
>                    ^~
> net/core/filter.c:4046:31: warning: unused variable ‘icsk’ [-Wunused-variable]
>   struct inet_connection_sock *icsk;
>                                ^~~~
> Move the variable declarations inside the {} block where they are used.
> 
> Fixes: 1e215300f138 ("bpf: add TCP_SAVE_SYN/TCP_SAVED_SYN options for bpf_(set|get)sockopt")
> Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
> ---
>  net/core/filter.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/core/filter.c b/net/core/filter.c
> index d301134bca3a..0ae7185b2207 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -4043,14 +4043,14 @@ static const struct bpf_func_proto bpf_setsockopt_proto = {
>  BPF_CALL_5(bpf_getsockopt, struct bpf_sock_ops_kern *, bpf_sock,
>  	   int, level, int, optname, char *, optval, int, optlen)
>  {
> -	struct inet_connection_sock *icsk;
>  	struct sock *sk = bpf_sock->sk;
> -	struct tcp_sock *tp;
>  
>  	if (!sk_fullsock(sk))
>  		goto err_clear;
>  #ifdef CONFIG_INET
>  	if (level == SOL_TCP && sk->sk_prot->getsockopt == tcp_getsockopt) {
> +		struct inet_connection_sock *icsk;
> +		struct tcp_sock *tp;
>  		switch (optname) {

I've added empty line after variable decl and applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-11 22:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-07 12:50 [PATCH] net/core/filter: fix unused-variable warning Anders Roxell
2018-09-11 22:13 ` Alexei Starovoitov

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