Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Ruan Jinjie <ruanjinjie@huawei.com>
To: <yonghong.song@linux.dev>, <Ast@kernel.org>,
	<Daniel@iogearbox.net>, <Andrii@kernel.org>,
	<Martin.lau@linux.dev>, <Song@kernel.org>,
	<John.fastabend@gmail.com>, <Kpsingh@kernel.org>,
	<Sdf@google.com>, <Haoluo@google.com>, <Jolsa@kernel.org>,
	<Mykolal@fb.com>, <Shuah@kernel.org>,
	<Benjamin.tissoires@redhat.com>, <Asavkov@redhat.com>,
	<Memxor@gmail.com>, <Iii@linux.ibm.com>, <Colin.i.king@gmail.com>,
	<Awkrail01@gmail.com>, <Rdunlap@infradead.org>,
	<Joannelkoong@gmail.com>, <bpf@vger.kernel.org>,
	<linux-kselftest@vger.kernel.org>
Subject: Re: [PATCH bpf-next v3] selftests/bpf: replace fall through comment by fallthrough pseudo-keyword
Date: Wed, 2 Aug 2023 09:30:59 +0800	[thread overview]
Message-ID: <2449f628-8265-818d-4090-409ef29d980e@huawei.com> (raw)
In-Reply-To: <172c46c3-c1bd-9628-0d20-fd51d79ec727@linux.dev>



On 2023/8/1 23:40, Yonghong Song wrote:
> 
> 
> On 8/1/23 2:48 AM, Ruan Jinjie wrote:
>> Replace the existing /* fall through */ comments with the
>> new pseudo-keyword macro fallthrough[1].
>>
>> [1]
>> https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through
>>
>> Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
>> ---
>> v3:
>> - Update the subject prefix and fix the 'fallthrough' undeclared build
>> error.
>> ---
>> v2:
>> - Update the subject and commit message.
>> ---
>>   tools/testing/selftests/bpf/prog_tests/kfunc_call.c          | 4 ++--
>>   tools/testing/selftests/bpf/progs/test_cls_redirect.c        | 2 +-
>>   tools/testing/selftests/bpf/progs/test_cls_redirect_dynptr.c | 2 +-
>>   tools/testing/selftests/bpf/test_verifier.c                  | 3 ++-
>>   4 files changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/tools/testing/selftests/bpf/prog_tests/kfunc_call.c
>> b/tools/testing/selftests/bpf/prog_tests/kfunc_call.c
>> index a543742cd7bd..0fd08172965a 100644
>> --- a/tools/testing/selftests/bpf/prog_tests/kfunc_call.c
>> +++ b/tools/testing/selftests/bpf/prog_tests/kfunc_call.c
>> @@ -101,7 +101,7 @@ static void verify_success(struct
>> kfunc_test_params *param)
>>       case syscall_test:
>>           topts.ctx_in = &args;
>>           topts.ctx_size_in = sizeof(args);
>> -        /* fallthrough */
>> +        fallthrough;
> 
> This won't work for clang built kernel/selftests:
> 
> In file included from progs/test_cls_redirect_subprogs.c:2:
> progs/test_cls_redirect.c:303:4: error: use of undeclared identifier
> 'fallthrough'
>   303 |                         fallthrough;
>       |                         ^
>   CLNG-BPF [test_maps] netns_cookie_prog.bpf.o
>   CLNG-BPF [test_maps] test_skmsg_load_helpers.bpf.o
>   CLNG-BPF [test_maps] bpf_iter_setsockopt.bpf.o
>   CLNG-BPF [test_maps] timer.bpf.o
> progs/test_cls_redirect.c:303:4: error: use of undeclared identifier
> 'fallthrough'
>   303 |                         fallthrough;
Thank you very much! I'll fix it in v4.

>       |                         ^
> 
> Try to build the kernel with:
>   make -j LLVM=1
>   make headers_install
> 
> and then build the selftests with
>   make -C tools/testing/selftests/bpf -j LLVM=1
> 
> [~/work/bpf-next/tools/include (master)]$ egrep -r fallthrough
> egrep: warning: egrep is obsolescent; using grep -E
> linux/compiler-gcc.h:#if __has_attribute(__fallthrough__)
> linux/compiler-gcc.h:# define fallthrough __attribute__((__fallthrough__))
> linux/compiler-gcc.h:# define fallthrough                    do {} while
> (0)  /* fallthrough */
> [~/work/bpf-next/tools/include (master)]$
> 
> Looks like 'fallthrough' is not defined for clang build tools/selftests.
> 
>>       case syscall_null_ctx_test:
>>           break;
>>       case tc_test:
>> @@ -167,7 +167,7 @@ static void verify_fail(struct kfunc_test_params
>> *param)
>>       case syscall_test:
>>           topts.ctx_in = &args;
>>           topts.ctx_size_in = sizeof(args);
>> -        /* fallthrough */
>> +        fallthrough;
>>       case syscall_null_ctx_test:
>>           break;
>>       case tc_test:
> [...]

      reply	other threads:[~2023-08-02  1:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01  9:48 [PATCH bpf-next v3] selftests/bpf: replace fall through comment by fallthrough pseudo-keyword Ruan Jinjie
2023-08-01 15:40 ` Yonghong Song
2023-08-02  1:30   ` Ruan Jinjie [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=2449f628-8265-818d-4090-409ef29d980e@huawei.com \
    --to=ruanjinjie@huawei.com \
    --cc=Andrii@kernel.org \
    --cc=Asavkov@redhat.com \
    --cc=Ast@kernel.org \
    --cc=Awkrail01@gmail.com \
    --cc=Benjamin.tissoires@redhat.com \
    --cc=Colin.i.king@gmail.com \
    --cc=Daniel@iogearbox.net \
    --cc=Haoluo@google.com \
    --cc=Iii@linux.ibm.com \
    --cc=Joannelkoong@gmail.com \
    --cc=John.fastabend@gmail.com \
    --cc=Jolsa@kernel.org \
    --cc=Kpsingh@kernel.org \
    --cc=Martin.lau@linux.dev \
    --cc=Memxor@gmail.com \
    --cc=Mykolal@fb.com \
    --cc=Rdunlap@infradead.org \
    --cc=Sdf@google.com \
    --cc=Shuah@kernel.org \
    --cc=Song@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=yonghong.song@linux.dev \
    /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