Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bpf: clean up unused-variable warning

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>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

authored by

Arnd Bergmann and committed by
Daniel Borkmann
a7dcdf6e cfd092f2

+1 -5
+1 -5
net/core/filter.c
··· 3381 3381 struct sock *sk = bpf_sock->sk; 3382 3382 int val = argval & BPF_SOCK_OPS_ALL_CB_FLAGS; 3383 3383 3384 - if (!sk_fullsock(sk)) 3384 + if (!IS_ENABLED(CONFIG_INET) || !sk_fullsock(sk)) 3385 3385 return -EINVAL; 3386 3386 3387 - #ifdef CONFIG_INET 3388 3387 if (val) 3389 3388 tcp_sk(sk)->bpf_sock_ops_cb_flags = val; 3390 3389 3391 3390 return argval & (~BPF_SOCK_OPS_ALL_CB_FLAGS); 3392 - #else 3393 - return -EINVAL; 3394 - #endif 3395 3391 } 3396 3392 3397 3393 static const struct bpf_func_proto bpf_sock_ops_cb_flags_set_proto = {