* [PATCH] bpf: clean up unused-variable warning
@ 2018-02-20 22:07 Arnd Bergmann
2018-02-22 0:12 ` Daniel Borkmann
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2018-02-20 22:07 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann
Cc: Arnd Bergmann, David S. Miller, John Fastabend, Lawrence Brakmo,
Jesper Dangaard Brouer, netdev, linux-kernel
The only user of this variable is inside of an #ifdef, causing
a warning without CONFIG_INET:
net/core/filter.c: In function '____bpf_sock_ops_cb_flags_set':
net/core/filter.c:3382:6: error: unused variable 'val' [-Werror=unused-variable]
int val = argval & BPF_SOCK_OPS_ALL_CB_FLAGS;
This replaces the #ifdef with a nicer IS_ENABLED() check that
makes the code more readable and avoids the warning.
Fixes: b13d88072172 ("bpf: Adds field bpf_sock_ops_cb_flags to tcp_sock")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
net/core/filter.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/net/core/filter.c b/net/core/filter.c
index 08ab4c65a998..0c121adbdbaa 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3381,17 +3381,13 @@ BPF_CALL_2(bpf_sock_ops_cb_flags_set, struct bpf_sock_ops_kern *, bpf_sock,
struct sock *sk = bpf_sock->sk;
int val = argval & BPF_SOCK_OPS_ALL_CB_FLAGS;
- if (!sk_fullsock(sk))
+ if (!IS_ENABLED(CONFIG_INET) || !sk_fullsock(sk))
return -EINVAL;
-#ifdef CONFIG_INET
if (val)
tcp_sk(sk)->bpf_sock_ops_cb_flags = val;
return argval & (~BPF_SOCK_OPS_ALL_CB_FLAGS);
-#else
- return -EINVAL;
-#endif
}
static const struct bpf_func_proto bpf_sock_ops_cb_flags_set_proto = {
--
2.9.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] bpf: clean up unused-variable warning
2018-02-20 22:07 [PATCH] bpf: clean up unused-variable warning Arnd Bergmann
@ 2018-02-22 0:12 ` Daniel Borkmann
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2018-02-22 0:12 UTC (permalink / raw)
To: Arnd Bergmann, Alexei Starovoitov
Cc: David S. Miller, John Fastabend, Lawrence Brakmo,
Jesper Dangaard Brouer, netdev, linux-kernel
On 02/20/2018 11:07 PM, Arnd Bergmann wrote:
> The only user of this variable is inside of an #ifdef, causing
> a warning without CONFIG_INET:
>
> net/core/filter.c: In function '____bpf_sock_ops_cb_flags_set':
> net/core/filter.c:3382:6: error: unused variable 'val' [-Werror=unused-variable]
> int val = argval & BPF_SOCK_OPS_ALL_CB_FLAGS;
>
> This replaces the #ifdef with a nicer IS_ENABLED() check that
> makes the code more readable and avoids the warning.
>
> Fixes: b13d88072172 ("bpf: Adds field bpf_sock_ops_cb_flags to tcp_sock")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Now applied to bpf, thanks Arnd!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-22 0:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-20 22:07 [PATCH] bpf: clean up unused-variable warning Arnd Bergmann
2018-02-22 0:12 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®