linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: Remove redundant checks in get_stack_print_output()
@ 2022-04-05 16:37 Yuntao Wang
  2022-04-05 23:52 ` Andrii Nakryiko
  0 siblings, 1 reply; 2+ messages in thread
From: Yuntao Wang @ 2022-04-05 16:37 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Shuah Khan, netdev, bpf, linux-kernel, linux-kselftest,
	Yuntao Wang

The checks preceding CHECK macro are redundant, remove them.

Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
---
 tools/testing/selftests/bpf/prog_tests/get_stack_raw_tp.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/get_stack_raw_tp.c b/tools/testing/selftests/bpf/prog_tests/get_stack_raw_tp.c
index 16048978a1ef..5f2ab720dabd 100644
--- a/tools/testing/selftests/bpf/prog_tests/get_stack_raw_tp.c
+++ b/tools/testing/selftests/bpf/prog_tests/get_stack_raw_tp.c
@@ -76,10 +76,8 @@ static void get_stack_print_output(void *ctx, int cpu, void *data, __u32 size)
 			good_user_stack = true;
 	}
 
-	if (!good_kern_stack)
-	    CHECK(!good_kern_stack, "kern_stack", "corrupted kernel stack\n");
-	if (!good_user_stack)
-	    CHECK(!good_user_stack, "user_stack", "corrupted user stack\n");
+	CHECK(!good_kern_stack, "kern_stack", "corrupted kernel stack\n");
+	CHECK(!good_user_stack, "user_stack", "corrupted user stack\n");
 }
 
 void test_get_stack_raw_tp(void)
-- 
2.35.1


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

* Re: [PATCH bpf-next] selftests/bpf: Remove redundant checks in get_stack_print_output()
  2022-04-05 16:37 [PATCH bpf-next] selftests/bpf: Remove redundant checks in get_stack_print_output() Yuntao Wang
@ 2022-04-05 23:52 ` Andrii Nakryiko
  0 siblings, 0 replies; 2+ messages in thread
From: Andrii Nakryiko @ 2022-04-05 23:52 UTC (permalink / raw)
  To: Yuntao Wang
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Shuah Khan, Networking, bpf, open list,
	open list:KERNEL SELFTEST FRAMEWORK

On Tue, Apr 5, 2022 at 9:39 AM Yuntao Wang <ytcoode@gmail.com> wrote:
>
> The checks preceding CHECK macro are redundant, remove them.
>
> Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
> ---
>  tools/testing/selftests/bpf/prog_tests/get_stack_raw_tp.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/get_stack_raw_tp.c b/tools/testing/selftests/bpf/prog_tests/get_stack_raw_tp.c
> index 16048978a1ef..5f2ab720dabd 100644
> --- a/tools/testing/selftests/bpf/prog_tests/get_stack_raw_tp.c
> +++ b/tools/testing/selftests/bpf/prog_tests/get_stack_raw_tp.c
> @@ -76,10 +76,8 @@ static void get_stack_print_output(void *ctx, int cpu, void *data, __u32 size)
>                         good_user_stack = true;
>         }
>
> -       if (!good_kern_stack)
> -           CHECK(!good_kern_stack, "kern_stack", "corrupted kernel stack\n");
> -       if (!good_user_stack)
> -           CHECK(!good_user_stack, "user_stack", "corrupted user stack\n");
> +       CHECK(!good_kern_stack, "kern_stack", "corrupted kernel stack\n");
> +       CHECK(!good_user_stack, "user_stack", "corrupted user stack\n");

I suspect it was to avoid super long verbose logs, as each CHECK()
emits one line into output and here we might be getting a lot of
samples. So let's keep it as is. But for the future let's try getting
rid of CHECK()s as much as possible in favor of ASSERT_xxx(). Thanks.

>  }
>
>  void test_get_stack_raw_tp(void)
> --
> 2.35.1
>

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

end of thread, other threads:[~2022-04-06  3:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-05 16:37 [PATCH bpf-next] selftests/bpf: Remove redundant checks in get_stack_print_output() Yuntao Wang
2022-04-05 23:52 ` Andrii Nakryiko

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