linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] samples: bpf: fix conflicting types in fds_example
@ 2021-12-01 16:49 Alexander Lobakin
  2021-12-01 20:57 ` Toke Høiland-Jørgensen
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexander Lobakin @ 2021-12-01 16:49 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: Alexander Lobakin, Maciej Fijalkowski, Magnus Karlsson,
	Michal Swiatkowski, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, netdev, bpf, linux-kernel

Fix the following samples/bpf build error appeared after the
introduction of bpf_map_create() in libbpf:

  CC  samples/bpf/fds_example.o
samples/bpf/fds_example.c:49:12: error: static declaration of 'bpf_map_create' follows non-static declaration
static int bpf_map_create(void)
           ^
samples/bpf/libbpf/include/bpf/bpf.h:55:16: note: previous declaration is here
LIBBPF_API int bpf_map_create(enum bpf_map_type map_type,
               ^
samples/bpf/fds_example.c:82:23: error: too few arguments to function call, expected 6, have 0
                fd = bpf_map_create();
                     ~~~~~~~~~~~~~~ ^
samples/bpf/libbpf/include/bpf/bpf.h:55:16: note: 'bpf_map_create' declared here
LIBBPF_API int bpf_map_create(enum bpf_map_type map_type,
               ^
2 errors generated.

fds_example by accident has a static function with the same name.
It's not worth it to separate a single call into its own function,
so just embed it.

Fixes: 992c4225419a ("libbpf: Unify low-level map creation APIs w/ new bpf_map_create()")
Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
 samples/bpf/fds_example.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/samples/bpf/fds_example.c b/samples/bpf/fds_example.c
index 59f45fef5110..9a7c1fd7a4a8 100644
--- a/samples/bpf/fds_example.c
+++ b/samples/bpf/fds_example.c
@@ -46,12 +46,6 @@ static void usage(void)
 	printf("       -h          Display this help.\n");
 }
 
-static int bpf_map_create(void)
-{
-	return bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(uint32_t),
-			      sizeof(uint32_t), 1024, 0);
-}
-
 static int bpf_prog_create(const char *object)
 {
 	static struct bpf_insn insns[] = {
@@ -79,7 +73,8 @@ static int bpf_do_map(const char *file, uint32_t flags, uint32_t key,
 	int fd, ret;
 
 	if (flags & BPF_F_PIN) {
-		fd = bpf_map_create();
+		fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(uint32_t),
+				    sizeof(uint32_t), 1024, 0);
 		printf("bpf: map fd:%d (%s)\n", fd, strerror(errno));
 		assert(fd > 0);
 
-- 
2.33.1


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

* Re: [PATCH bpf-next] samples: bpf: fix conflicting types in fds_example
  2021-12-01 16:49 [PATCH bpf-next] samples: bpf: fix conflicting types in fds_example Alexander Lobakin
@ 2021-12-01 20:57 ` Toke Høiland-Jørgensen
  2021-12-01 22:31 ` Andrii Nakryiko
  2021-12-01 22:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Toke Høiland-Jørgensen @ 2021-12-01 20:57 UTC (permalink / raw)
  To: Alexander Lobakin, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: Alexander Lobakin, Maciej Fijalkowski, Magnus Karlsson,
	Michal Swiatkowski, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, netdev, bpf, linux-kernel

Alexander Lobakin <alexandr.lobakin@intel.com> writes:

> Fix the following samples/bpf build error appeared after the
> introduction of bpf_map_create() in libbpf:
>
>   CC  samples/bpf/fds_example.o
> samples/bpf/fds_example.c:49:12: error: static declaration of 'bpf_map_create' follows non-static declaration
> static int bpf_map_create(void)
>            ^
> samples/bpf/libbpf/include/bpf/bpf.h:55:16: note: previous declaration is here
> LIBBPF_API int bpf_map_create(enum bpf_map_type map_type,
>                ^
> samples/bpf/fds_example.c:82:23: error: too few arguments to function call, expected 6, have 0
>                 fd = bpf_map_create();
>                      ~~~~~~~~~~~~~~ ^
> samples/bpf/libbpf/include/bpf/bpf.h:55:16: note: 'bpf_map_create' declared here
> LIBBPF_API int bpf_map_create(enum bpf_map_type map_type,
>                ^
> 2 errors generated.
>
> fds_example by accident has a static function with the same name.
> It's not worth it to separate a single call into its own function,
> so just embed it.
>
> Fixes: 992c4225419a ("libbpf: Unify low-level map creation APIs w/ new bpf_map_create()")
> Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com>
> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

I just ran into this today as well - thanks for the fix!

Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>


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

* Re: [PATCH bpf-next] samples: bpf: fix conflicting types in fds_example
  2021-12-01 16:49 [PATCH bpf-next] samples: bpf: fix conflicting types in fds_example Alexander Lobakin
  2021-12-01 20:57 ` Toke Høiland-Jørgensen
@ 2021-12-01 22:31 ` Andrii Nakryiko
  2021-12-01 22:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Andrii Nakryiko @ 2021-12-01 22:31 UTC (permalink / raw)
  To: Alexander Lobakin
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Maciej Fijalkowski, Magnus Karlsson, Michal Swiatkowski,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Networking, bpf, open list

On Wed, Dec 1, 2021 at 8:50 AM Alexander Lobakin
<alexandr.lobakin@intel.com> wrote:
>
> Fix the following samples/bpf build error appeared after the
> introduction of bpf_map_create() in libbpf:
>
>   CC  samples/bpf/fds_example.o
> samples/bpf/fds_example.c:49:12: error: static declaration of 'bpf_map_create' follows non-static declaration
> static int bpf_map_create(void)
>            ^
> samples/bpf/libbpf/include/bpf/bpf.h:55:16: note: previous declaration is here
> LIBBPF_API int bpf_map_create(enum bpf_map_type map_type,
>                ^
> samples/bpf/fds_example.c:82:23: error: too few arguments to function call, expected 6, have 0
>                 fd = bpf_map_create();
>                      ~~~~~~~~~~~~~~ ^
> samples/bpf/libbpf/include/bpf/bpf.h:55:16: note: 'bpf_map_create' declared here
> LIBBPF_API int bpf_map_create(enum bpf_map_type map_type,
>                ^
> 2 errors generated.
>
> fds_example by accident has a static function with the same name.
> It's not worth it to separate a single call into its own function,
> so just embed it.
>
> Fixes: 992c4225419a ("libbpf: Unify low-level map creation APIs w/ new bpf_map_create()")
> Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com>
> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
>  samples/bpf/fds_example.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/samples/bpf/fds_example.c b/samples/bpf/fds_example.c
> index 59f45fef5110..9a7c1fd7a4a8 100644
> --- a/samples/bpf/fds_example.c
> +++ b/samples/bpf/fds_example.c
> @@ -46,12 +46,6 @@ static void usage(void)
>         printf("       -h          Display this help.\n");
>  }
>
> -static int bpf_map_create(void)
> -{
> -       return bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(uint32_t),
> -                             sizeof(uint32_t), 1024, 0);
> -}
> -
>  static int bpf_prog_create(const char *object)
>  {
>         static struct bpf_insn insns[] = {
> @@ -79,7 +73,8 @@ static int bpf_do_map(const char *file, uint32_t flags, uint32_t key,
>         int fd, ret;
>
>         if (flags & BPF_F_PIN) {
> -               fd = bpf_map_create();
> +               fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(uint32_t),
> +                                   sizeof(uint32_t), 1024, 0);

Would be even better to use bpf_map_create() API instead, but that's
fine, I'm sending a big clean up patch for this and other uses of
deprecated APIs in samples/bpf. Applied to bpf-next.

>                 printf("bpf: map fd:%d (%s)\n", fd, strerror(errno));
>                 assert(fd > 0);
>
> --
> 2.33.1
>

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

* Re: [PATCH bpf-next] samples: bpf: fix conflicting types in fds_example
  2021-12-01 16:49 [PATCH bpf-next] samples: bpf: fix conflicting types in fds_example Alexander Lobakin
  2021-12-01 20:57 ` Toke Høiland-Jørgensen
  2021-12-01 22:31 ` Andrii Nakryiko
@ 2021-12-01 22:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-12-01 22:40 UTC (permalink / raw)
  To: Alexander Lobakin
  Cc: ast, daniel, andrii, maciej.fijalkowski, magnus.karlsson,
	michal.swiatkowski, kafai, songliubraving, yhs, john.fastabend,
	kpsingh, netdev, bpf, linux-kernel

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Wed,  1 Dec 2021 17:49:31 +0100 you wrote:
> Fix the following samples/bpf build error appeared after the
> introduction of bpf_map_create() in libbpf:
> 
>   CC  samples/bpf/fds_example.o
> samples/bpf/fds_example.c:49:12: error: static declaration of 'bpf_map_create' follows non-static declaration
> static int bpf_map_create(void)
>            ^
> samples/bpf/libbpf/include/bpf/bpf.h:55:16: note: previous declaration is here
> LIBBPF_API int bpf_map_create(enum bpf_map_type map_type,
>                ^
> samples/bpf/fds_example.c:82:23: error: too few arguments to function call, expected 6, have 0
>                 fd = bpf_map_create();
>                      ~~~~~~~~~~~~~~ ^
> samples/bpf/libbpf/include/bpf/bpf.h:55:16: note: 'bpf_map_create' declared here
> LIBBPF_API int bpf_map_create(enum bpf_map_type map_type,
>                ^
> 2 errors generated.
> 
> [...]

Here is the summary with links:
  - [bpf-next] samples: bpf: fix conflicting types in fds_example
    https://git.kernel.org/bpf/bpf-next/c/64b5b97b8cff

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-12-01 22:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-01 16:49 [PATCH bpf-next] samples: bpf: fix conflicting types in fds_example Alexander Lobakin
2021-12-01 20:57 ` Toke Høiland-Jørgensen
2021-12-01 22:31 ` Andrii Nakryiko
2021-12-01 22:40 ` patchwork-bot+netdevbpf

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