mbox series

[v2,0/2] drop duplicate max/min definitions

Message ID cover.1649424565.git.geliang.tang@suse.com
Headers show
Series drop duplicate max/min definitions | expand

Message

Geliang Tang April 8, 2022, 1:36 p.m. UTC
Two small cleanups for selftests, drop duplicate max/min definitions.

v2:
 - do more cleanups as Daniel suggested.

v1:
 - "selftests: bpf: use MIN for TCP CC tests"

Geliang Tang (2):
  selftests: bpf: drop duplicate max/min definitions
  selftests: mqueue: drop duplicate min definition

 tools/testing/selftests/bpf/prog_tests/bpf_iter.c    | 5 ++---
 tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c  | 7 +++----
 tools/testing/selftests/bpf/prog_tests/snprintf.c    | 5 ++---
 tools/testing/selftests/bpf/prog_tests/tc_redirect.c | 2 +-
 tools/testing/selftests/mqueue/mq_perf_tests.c       | 4 ++--
 5 files changed, 10 insertions(+), 13 deletions(-)

Comments

Shuah Khan April 8, 2022, 7:15 p.m. UTC | #1
On 4/8/22 7:36 AM, Geliang Tang wrote:
> Drop duplicate macros min() and MAX() definitions in prog_tests, use MIN()
> or MAX() in sys/param.h instead.
> 
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> ---
>   tools/testing/selftests/bpf/prog_tests/bpf_iter.c    | 5 ++---
>   tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c  | 7 +++----
>   tools/testing/selftests/bpf/prog_tests/snprintf.c    | 5 ++---
>   tools/testing/selftests/bpf/prog_tests/tc_redirect.c | 2 +-
>   4 files changed, 8 insertions(+), 11 deletions(-)
> 

Looks good to me. Thanks for cleaning these up.

Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah
Daniel Borkmann April 8, 2022, 8:31 p.m. UTC | #2
On 4/8/22 3:36 PM, Geliang Tang wrote:
> Drop duplicate macros min() and MAX() definitions in prog_tests, use MIN()
> or MAX() in sys/param.h instead.
> 
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
[...]

Thanks Geliang! One small final nit and then it's good to go to bpf-next:

> diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
> index 5142a7d130b2..86561c0b0dea 100644
> --- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
> +++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
> @@ -1,5 +1,6 @@
>   // SPDX-License-Identifier: GPL-2.0
>   /* Copyright (c) 2020 Facebook */
> +#include <sys/param.h>
>   #include <test_progs.h>
>   #include "bpf_iter_ipv6_route.skel.h"
>   #include "bpf_iter_netlink.skel.h"
[...]

> diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
> index 8f7a1cef7d87..ceed369361fc 100644
> --- a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
> +++ b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
> @@ -3,6 +3,7 @@
>   
>   #include <linux/err.h>
>   #include <netinet/tcp.h>
> +#include <sys/param.h>
>   #include <test_progs.h>
>   #include "network_helpers.h"
>   #include "bpf_dctcp.skel.h"
[...]

> diff --git a/tools/testing/selftests/bpf/prog_tests/snprintf.c b/tools/testing/selftests/bpf/prog_tests/snprintf.c
> index 394ebfc3bbf3..5ca70aa15c4a 100644
> --- a/tools/testing/selftests/bpf/prog_tests/snprintf.c
> +++ b/tools/testing/selftests/bpf/prog_tests/snprintf.c
> @@ -1,6 +1,7 @@
>   // SPDX-License-Identifier: GPL-2.0
>   /* Copyright (c) 2021 Google LLC. */
>   
> +#include <sys/param.h>
>   #include <test_progs.h>
>   #include "test_snprintf.skel.h"
>   #include "test_snprintf_single.skel.h"
> @@ -83,8 +84,6 @@ static void test_snprintf_positive(void)
[...]

> diff --git a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
> index 7ad66a247c02..52f1b9139145 100644
> --- a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
> +++ b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
> @@ -20,6 +20,7 @@
>   #include <stdbool.h>
>   #include <stdio.h>
>   #include <sys/stat.h>
> +#include <sys/param.h>
>   #include <unistd.h>
>   
>   #include "test_progs.h"

Just add the sys/param.h to the test_progs.h header in BPF selftests where we also pull
in other sys headers; then all the duplicate includes above are not needed.

Thanks,
Daniel