mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Liao Chang <liaochang1@huawei.com>,
	ast@kernel.org, andrii@kernel.org, martin.lau@linux.dev,
	song@kernel.org, yhs@fb.com, john.fastabend@gmail.com,
	kpsingh@kernel.org, sdf@google.com, haoluo@google.com,
	jolsa@kernel.org
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] samples/bpf: Fix duplicate struct define in test_lru_dist sample
Date: Fri, 18 Nov 2022 23:29:07 +0100	[thread overview]
Message-ID: <109e3d8a-26c6-44c8-aabe-04d5c47ec9c8@iogearbox.net> (raw)
In-Reply-To: <20221118004752.97759-1-liaochang1@huawei.com>

On 11/18/22 1:47 AM, Liao Chang wrote:
> Build sample/bpf report error as follow:
> 
>    CC  ./samples/bpf/test_lru_dist
> ./samples/bpf/test_lru_dist.c:35:8: error: redefinition of ‘struct list_head’
>     35 | struct list_head {
>        |        ^~~~~~~~~
> In file included from ./samples/bpf/test_lru_dist.c:6:
> ./tools/include/linux/types.h:84:8: note: originally defined here
>     84 | struct list_head {
> 
> Remove the duplicate definition of struct list_head in test_lru_dist.c
> 
> Signed-off-by: Liao Chang <liaochang1@huawei.com>
> ---
>   samples/bpf/test_lru_dist.c | 4 ----
>   1 file changed, 4 deletions(-)
> 
> diff --git a/samples/bpf/test_lru_dist.c b/samples/bpf/test_lru_dist.c
> index 5efb91763d65..2e7341044090 100644
> --- a/samples/bpf/test_lru_dist.c
> +++ b/samples/bpf/test_lru_dist.c
> @@ -32,10 +32,6 @@ static int nr_cpus;
>   static unsigned long long *dist_keys;
>   static unsigned int dist_key_counts;
>   
> -struct list_head {
> -	struct list_head *next, *prev;
> -};
> -

This will actually break it, see CI:

https://github.com/kernel-patches/bpf/actions/runs/3500019006/jobs/5862316961

   [...]
   CLANG-bpf  /tmp/work/bpf/bpf/samples/bpf/lathist_kern.o
     CLANG-bpf  /tmp/work/bpf/bpf/samples/bpf/offwaketime_kern.o
     CLANG-bpf  /tmp/work/bpf/bpf/samples/bpf/spintest_kern.o
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:35:42: warning: ‘struct list_head’ declared inside parameter list will not be visible outside of this definition or declaration
      35 | static inline void INIT_LIST_HEAD(struct list_head *list)
         |                                          ^~~~~~~~~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c: In function ‘INIT_LIST_HEAD’:
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:37:6: error: dereferencing pointer to incomplete type ‘struct list_head’
      37 |  list->next = list;
         |      ^~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c: At top level:
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:41:43: warning: ‘struct list_head’ declared inside parameter list will not be visible outside of this definition or declaration
      41 | static inline int list_empty(const struct list_head *head)
         |                                           ^~~~~~~~~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c: In function ‘list_empty’:
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:43:13: error: dereferencing pointer to incomplete type ‘const struct list_head’
      43 |  return head->next == head;
         |             ^~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c: At top level:
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:46:38: warning: ‘struct list_head’ declared inside parameter list will not be visible outside of this definition or declaration
      46 | static inline void __list_add(struct list_head *new,
         |                                      ^~~~~~~~~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c: In function ‘__list_add’:
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:50:6: error: dereferencing pointer to incomplete type ‘struct list_head’
      50 |  next->prev = new;
         |      ^~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c: At top level:
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:56:36: warning: ‘struct list_head’ declared inside parameter list will not be visible outside of this definition or declaration
      56 | static inline void list_add(struct list_head *new, struct list_head *head)
         |                                    ^~~~~~~~~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c: In function ‘list_add’:
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:58:28: error: dereferencing pointer to incomplete type ‘struct list_head’
      58 |  __list_add(new, head, head->next);
     CLANG-bpf  /tmp/work/bpf/bpf/samples/bpf/map_perf_test_kern.o
         |                            ^~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:58:13: warning: passing argument 1 of ‘__list_add’ from incompatible pointer type [-Wincompatible-pointer-types]
      58 |  __list_add(new, head, head->next);
         |             ^~~
         |             |
         |             struct list_head *
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:46:49: note: expected ‘struct list_head *’ but argument is of type ‘struct list_head *’
      46 | static inline void __list_add(struct list_head *new,
         |                               ~~~~~~~~~~~~~~~~~~^~~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:58:18: warning: passing argument 2 of ‘__list_add’ from incompatible pointer type [-Wincompatible-pointer-types]
      58 |  __list_add(new, head, head->next);
         |                  ^~~~
         |                  |
         |                  struct list_head *
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:47:28: note: expected ‘struct list_head *’ but argument is of type ‘struct list_head *’
      47 |          struct list_head *prev,
         |          ~~~~~~~~~~~~~~~~~~^~~~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c: At top level:
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:61:38: warning: ‘struct list_head’ declared inside parameter list will not be visible outside of this definition or declaration
      61 | static inline void __list_del(struct list_head *prev, struct list_head *next)
         |                                      ^~~~~~~~~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c: In function ‘__list_del’:
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:63:6: error: dereferencing pointer to incomplete type ‘struct list_head’
      63 |  next->prev = prev;
         |      ^~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c: At top level:
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:67:44: warning: ‘struct list_head’ declared inside parameter list will not be visible outside of this definition or declaration
      67 | static inline void __list_del_entry(struct list_head *entry)
         |                                            ^~~~~~~~~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c: In function ‘__list_del_entry’:
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:69:18: error: dereferencing pointer to incomplete type ‘struct list_head’
      69 |  __list_del(entry->prev, entry->next);
         |                  ^~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c: At top level:
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:72:37: warning: ‘struct list_head’ declared inside parameter list will not be visible outside of this definition or declaration
      72 | static inline void list_move(struct list_head *list, struct list_head *head)
         |                                     ^~~~~~~~~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c: In function ‘list_move’:
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:74:19: warning: passing argument 1 of ‘__list_del_entry’ from incompatible pointer type [-Wincompatible-pointer-types]
      74 |  __list_del_entry(list);
         |                   ^~~~
         |                   |
         |                   struct list_head *
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:67:55: note: expected ‘struct list_head *’ but argument is of type ‘struct list_head *’
      67 | static inline void __list_del_entry(struct list_head *entry)
         |                                     ~~~~~~~~~~~~~~~~~~^~~~~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:75:11: warning: passing argument 1 of ‘list_add’ from incompatible pointer type [-Wincompatible-pointer-types]
      75 |  list_add(list, head);
         |           ^~~~
         |           |
         |           struct list_head *
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:56:47: note: expected ‘struct list_head *’ but argument is of type ‘struct list_head *’
      56 | static inline void list_add(struct list_head *new, struct list_head *head)
         |                             ~~~~~~~~~~~~~~~~~~^~~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:75:17: warning: passing argument 2 of ‘list_add’ from incompatible pointer type [-Wincompatible-pointer-types]
      75 |  list_add(list, head);
         |                 ^~~~
         |                 |
         |                 struct list_head *
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:56:70: note: expected ‘struct list_head *’ but argument is of type ‘struct list_head *’
      56 | static inline void list_add(struct list_head *new, struct list_head *head)
         |                                                    ~~~~~~~~~~~~~~~~~~^~~~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c: At top level:
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:85:19: error: field ‘list’ has incomplete type
      85 |  struct list_head list;
         |                   ^~~~
   /tmp/work/bpf/bpf/samples/bpf/test_lru_dist.c:90:19: error: field ‘list’ has incomplete type
      90 |  struct list_head list;
         |                   ^~~~
     CLANG-bpf  /tmp/work/bpf/bpf/samples/bpf/test_overhead_tp_kern.o
   make[3]: *** [/tmp/work/bpf/bpf/samples/bpf/Makefile.target:58: /tmp/work/bpf/bpf/samples/bpf/test_lru_dist] Error 1
   make[3]: *** Waiting for unfinished jobs....
     LD      /tmp/work/bpf/bpf/samples/bpf/bpftool/bootstrap/libbpf/staticobjs/libbpf-in.o
     LINK    /tmp/work/bpf/bpf/samples/bpf/bpftool/bootstrap/libbpf/libbpf.a
     CC      /tmp/work/bpf/bpf/samples/bpf/bpftool/bootstrap/main.o
     CC      /tmp/work/bpf/bpf/samples/bpf/bpftool/bootstrap/common.o
     CC      /tmp/work/bpf/bpf/samples/bpf/bpftool/bootstrap/json_writer.o
     CC      /tmp/work/bpf/bpf/samples/bpf/bpftool/bootstrap/gen.o
     CC      /tmp/work/bpf/bpf/samples/bpf/bpftool/bootstrap/btf.o
     CC      /tmp/work/bpf/bpf/samples/bpf/bpftool/bootstrap/xlated_dumper.o
     CC      /tmp/work/bpf/bpf/samples/bpf/bpftool/bootstrap/btf_dumper.o
     CC      /tmp/work/bpf/bpf/samples/bpf/bpftool/bootstrap/disasm.o
     LINK    /tmp/work/bpf/bpf/samples/bpf/bpftool/bootstrap/bpftool
   make[2]: *** [/tmp/work/bpf/bpf/Makefile:1992: /tmp/work/bpf/bpf/samples/bpf] Error 2
   make[2]: Leaving directory '/tmp/work/bpf/bpf/kbuild-output'
   make[1]: *** [Makefile:231: __sub-make] Error 2
   make[1]: Leaving directory '/tmp/work/bpf/bpf'
   make: *** [Makefile:269: all] Error 2
   make: Leaving directory '/tmp/work/bpf/bpf/samples/bpf'
   Error: Process completed with exit code 2.

      reply	other threads:[~2022-11-18 22:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-18  0:47 Liao Chang
2022-11-18 22:29 ` Daniel Borkmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=109e3d8a-26c6-44c8-aabe-04d5c47ec9c8@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=liaochang1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®