Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Drop duplicate max/min definitions

Drop duplicate macros min() and MAX() definitions in prog_tests and use
MIN() or MAX() in sys/param.h instead.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/1ae276da9925c2de59b5bdc93b693b4c243e692e.1649462033.git.geliang.tang@suse.com

authored by

Geliang Tang and committed by
Daniel Borkmann
f4fd706f dd642ccb

+5 -11
+1 -3
tools/testing/selftests/bpf/prog_tests/bpf_iter.c
··· 1192 1192 *dst = '\0'; 1193 1193 } 1194 1194 1195 - #define min(a, b) ((a) < (b) ? (a) : (b)) 1196 - 1197 1195 static void test_task_vma(void) 1198 1196 { 1199 1197 int err, iter_fd = -1, proc_maps_fd = -1; ··· 1227 1229 len = 0; 1228 1230 while (len < CMP_BUFFER_SIZE) { 1229 1231 err = read_fd_into_buffer(iter_fd, task_vma_output + len, 1230 - min(read_size, CMP_BUFFER_SIZE - len)); 1232 + MIN(read_size, CMP_BUFFER_SIZE - len)); 1231 1233 if (!err) 1232 1234 break; 1233 1235 if (CHECK(err < 0, "read_iter_fd", "read_iter_fd failed\n"))
+2 -4
tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
··· 10 10 #include "bpf_tcp_nogpl.skel.h" 11 11 #include "bpf_dctcp_release.skel.h" 12 12 13 - #define min(a, b) ((a) < (b) ? (a) : (b)) 14 - 15 13 #ifndef ENOTSUPP 16 14 #define ENOTSUPP 524 17 15 #endif ··· 51 53 52 54 while (bytes < total_bytes && !READ_ONCE(stop)) { 53 55 nr_sent = send(fd, &batch, 54 - min(total_bytes - bytes, sizeof(batch)), 0); 56 + MIN(total_bytes - bytes, sizeof(batch)), 0); 55 57 if (nr_sent == -1 && errno == EINTR) 56 58 continue; 57 59 if (nr_sent == -1) { ··· 144 146 /* recv total_bytes */ 145 147 while (bytes < total_bytes && !READ_ONCE(stop)) { 146 148 nr_recv = recv(fd, &batch, 147 - min(total_bytes - bytes, sizeof(batch)), 0); 149 + MIN(total_bytes - bytes, sizeof(batch)), 0); 148 150 if (nr_recv == -1 && errno == EINTR) 149 151 continue; 150 152 if (nr_recv == -1)
+1 -3
tools/testing/selftests/bpf/prog_tests/snprintf.c
··· 83 83 test_snprintf__destroy(skel); 84 84 } 85 85 86 - #define min(a, b) ((a) < (b) ? (a) : (b)) 87 - 88 86 /* Loads an eBPF object calling bpf_snprintf with up to 10 characters of fmt */ 89 87 static int load_single_snprintf(char *fmt) 90 88 { ··· 93 95 if (!skel) 94 96 return -EINVAL; 95 97 96 - memcpy(skel->rodata->fmt, fmt, min(strlen(fmt) + 1, 10)); 98 + memcpy(skel->rodata->fmt, fmt, MIN(strlen(fmt) + 1, 10)); 97 99 98 100 ret = test_snprintf_single__load(skel); 99 101 test_snprintf_single__destroy(skel);
-1
tools/testing/selftests/bpf/prog_tests/tc_redirect.c
··· 949 949 return -1; 950 950 } 951 951 952 - #define MAX(a, b) ((a) > (b) ? (a) : (b)) 953 952 enum { 954 953 SRC_TO_TARGET = 0, 955 954 TARGET_TO_SRC = 1,
+1
tools/testing/selftests/bpf/test_progs.h
··· 25 25 #include <sys/wait.h> 26 26 #include <sys/types.h> 27 27 #include <sys/time.h> 28 + #include <sys/param.h> 28 29 #include <fcntl.h> 29 30 #include <pthread.h> 30 31 #include <linux/bpf.h>