Use macro MIN() in sys/param.h for TCP CC tests, instead of defining a new one.
Signed-off-by: Geliang Tang geliang.tang@suse.com --- tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
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" @@ -10,8 +11,6 @@ #include "bpf_tcp_nogpl.skel.h" #include "bpf_dctcp_release.skel.h"
-#define min(a, b) ((a) < (b) ? (a) : (b)) - #ifndef ENOTSUPP #define ENOTSUPP 524 #endif @@ -53,7 +52,7 @@ static void *server(void *arg)
while (bytes < total_bytes && !READ_ONCE(stop)) { nr_sent = send(fd, &batch, - min(total_bytes - bytes, sizeof(batch)), 0); + MIN(total_bytes - bytes, sizeof(batch)), 0); if (nr_sent == -1 && errno == EINTR) continue; if (nr_sent == -1) { @@ -146,7 +145,7 @@ static void do_test(const char *tcp_ca, const struct bpf_map *sk_stg_map) /* recv total_bytes */ while (bytes < total_bytes && !READ_ONCE(stop)) { nr_recv = recv(fd, &batch, - min(total_bytes - bytes, sizeof(batch)), 0); + MIN(total_bytes - bytes, sizeof(batch)), 0); if (nr_recv == -1 && errno == EINTR) continue; if (nr_recv == -1)
On 4/6/22 10:19 PM, Geliang Tang wrote:
Use macro MIN() in sys/param.h for TCP CC tests, instead of defining a new one.
Signed-off-by: Geliang Tang geliang.tang@suse.com
tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
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" @@ -10,8 +11,6 @@ #include "bpf_tcp_nogpl.skel.h" #include "bpf_dctcp_release.skel.h" -#define min(a, b) ((a) < (b) ? (a) : (b))
Thank you for cleaning this up. Sanity compile test passed.
Reviewed-by: Shuah Khan skhan@linuxfoundation.org
thanks, -- Shuah
Hi Geliang,
On 4/7/22 6:19 AM, Geliang Tang wrote:
Use macro MIN() in sys/param.h for TCP CC tests, instead of defining a new one.
Signed-off-by: Geliang Tang geliang.tang@suse.com
Thanks for your cleanup; we do seem to have this in a bunch of places:
tools/testing/selftests/bpf/prog_tests/bpf_iter.c:1195:#define min(a, b) ((a) < (b) ? (a) : (b)) tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c:13:#define min(a, b) ((a) < (b) ? (a) : (b)) tools/testing/selftests/bpf/prog_tests/snprintf.c:86:#define min(a, b) ((a) < (b) ? (a) : (b))
Mind sending a v2 which cleans up all at once to reduce too much churn?
Thanks, Daniel
linux-kselftest-mirror@lists.linaro.org