All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bpf: fix unused variable warning
@ 2020-04-29 13:21 Arnd Bergmann
  2020-04-29 20:36 ` Andrii Nakryiko
  2020-04-29 23:15 ` Daniel Borkmann
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2020-04-29 13:21 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: Arnd Bergmann, Martin KaFai Lau, Song Liu, Yonghong Song, netdev,
	bpf, linux-kernel

Hiding the only using of bpf_link_type_strs[] in an #ifdef causes
an unused-variable warning:

kernel/bpf/syscall.c:2280:20: error: 'bpf_link_type_strs' defined but not used [-Werror=unused-variable]
 2280 | static const char *bpf_link_type_strs[] = {

Move the definition into the same #ifdef.

Fixes: f2e10bff16a0 ("bpf: Add support for BPF_OBJ_GET_INFO_BY_FD for bpf_link")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/bpf/syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 3cea7602de78..5e86d8749e6e 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -2274,6 +2274,7 @@ static int bpf_link_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
+#ifdef CONFIG_PROC_FS
 #define BPF_PROG_TYPE(_id, _name, prog_ctx_type, kern_ctx_type)
 #define BPF_MAP_TYPE(_id, _ops)
 #define BPF_LINK_TYPE(_id, _name) [_id] = #_name,
@@ -2285,7 +2286,6 @@ static const char *bpf_link_type_strs[] = {
 #undef BPF_MAP_TYPE
 #undef BPF_LINK_TYPE
 
-#ifdef CONFIG_PROC_FS
 static void bpf_link_show_fdinfo(struct seq_file *m, struct file *filp)
 {
 	const struct bpf_link *link = filp->private_data;
-- 
2.26.0


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

* Re: [PATCH] bpf: fix unused variable warning
  2020-04-29 13:21 [PATCH] bpf: fix unused variable warning Arnd Bergmann
@ 2020-04-29 20:36 ` Andrii Nakryiko
  2020-04-29 23:15 ` Daniel Borkmann
  1 sibling, 0 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2020-04-29 20:36 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, Networking, bpf,
	open list

On Wed, Apr 29, 2020 at 6:23 AM Arnd Bergmann <arnd@arndb.de> wrote:
>
> Hiding the only using of bpf_link_type_strs[] in an #ifdef causes
> an unused-variable warning:
>
> kernel/bpf/syscall.c:2280:20: error: 'bpf_link_type_strs' defined but not used [-Werror=unused-variable]
>  2280 | static const char *bpf_link_type_strs[] = {
>
> Move the definition into the same #ifdef.
>
> Fixes: f2e10bff16a0 ("bpf: Add support for BPF_OBJ_GET_INFO_BY_FD for bpf_link")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---

Thanks for the fix, LGTM.

Acked-by: Andrii Nakryiko <andriin@fb.com>

>  kernel/bpf/syscall.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 3cea7602de78..5e86d8749e6e 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -2274,6 +2274,7 @@ static int bpf_link_release(struct inode *inode, struct file *filp)
>         return 0;
>  }
>
> +#ifdef CONFIG_PROC_FS
>  #define BPF_PROG_TYPE(_id, _name, prog_ctx_type, kern_ctx_type)
>  #define BPF_MAP_TYPE(_id, _ops)
>  #define BPF_LINK_TYPE(_id, _name) [_id] = #_name,
> @@ -2285,7 +2286,6 @@ static const char *bpf_link_type_strs[] = {
>  #undef BPF_MAP_TYPE
>  #undef BPF_LINK_TYPE
>
> -#ifdef CONFIG_PROC_FS
>  static void bpf_link_show_fdinfo(struct seq_file *m, struct file *filp)
>  {
>         const struct bpf_link *link = filp->private_data;
> --
> 2.26.0
>

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

* Re: [PATCH] bpf: fix unused variable warning
  2020-04-29 13:21 [PATCH] bpf: fix unused variable warning Arnd Bergmann
  2020-04-29 20:36 ` Andrii Nakryiko
@ 2020-04-29 23:15 ` Daniel Borkmann
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2020-04-29 23:15 UTC (permalink / raw)
  To: Arnd Bergmann, Alexei Starovoitov, Andrii Nakryiko
  Cc: Martin KaFai Lau, Song Liu, Yonghong Song, netdev, bpf, linux-kernel

On 4/29/20 3:21 PM, Arnd Bergmann wrote:
> Hiding the only using of bpf_link_type_strs[] in an #ifdef causes
> an unused-variable warning:
> 
> kernel/bpf/syscall.c:2280:20: error: 'bpf_link_type_strs' defined but not used [-Werror=unused-variable]
>   2280 | static const char *bpf_link_type_strs[] = {
> 
> Move the definition into the same #ifdef.
> 
> Fixes: f2e10bff16a0 ("bpf: Add support for BPF_OBJ_GET_INFO_BY_FD for bpf_link")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied, thanks!

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

end of thread, other threads:[~2020-04-29 23:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29 13:21 [PATCH] bpf: fix unused variable warning Arnd Bergmann
2020-04-29 20:36 ` Andrii Nakryiko
2020-04-29 23:15 ` Daniel Borkmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.