summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <alx.manpages@gmail.com>2021-11-19 19:14:30 +0100
committerAlejandro Colomar <alx.manpages@gmail.com>2021-11-20 14:45:33 +0100
commitbbc657cb231da482bf85edb576043ef49ca4ec69 (patch)
tree0d0f20711e715efb85e3e6f1ddc4c461dda12a28
parentf5eae2dee077ee8f78324efcbee2977482329249 (diff)
tools/testing/selftests/net/: Don't redefine ARRAY_SIZE()
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
-rw-r--r--tools/testing/selftests/net/gro.c4
-rw-r--r--tools/testing/selftests/net/ipsec.c4
-rw-r--r--tools/testing/selftests/net/reuseport_bpf.c5
-rw-r--r--tools/testing/selftests/net/rxtimestamp.c2
-rw-r--r--tools/testing/selftests/net/socket.c5
-rw-r--r--tools/testing/selftests/net/tcp_fastopen_backup_key.c8
6 files changed, 17 insertions, 11 deletions
diff --git a/tools/testing/selftests/net/gro.c b/tools/testing/selftests/net/gro.c
index cf37ce86b0fd..fd8209c8cc3c 100644
--- a/tools/testing/selftests/net/gro.c
+++ b/tools/testing/selftests/net/gro.c
@@ -35,12 +35,14 @@
*
*/
+
#define _GNU_SOURCE
#include <arpa/inet.h>
#include <errno.h>
#include <error.h>
#include <getopt.h>
+#include <linux/array_size.h>
#include <linux/filter.h>
#include <linux/if_packet.h>
#include <linux/ipv6.h>
@@ -57,10 +59,10 @@
#include <string.h>
#include <unistd.h>
+
#define DPORT 8000
#define SPORT 1500
#define PAYLOAD_LEN 100
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#define NUM_PACKETS 4
#define START_SEQ 100
#define START_ACK 100
diff --git a/tools/testing/selftests/net/ipsec.c b/tools/testing/selftests/net/ipsec.c
index 3d7dde2c321b..74d1612c74b3 100644
--- a/tools/testing/selftests/net/ipsec.c
+++ b/tools/testing/selftests/net/ipsec.c
@@ -4,6 +4,7 @@
* Copyright (c) 2018 Dmitry Safonov
*/
+
#define _GNU_SOURCE
#include <arpa/inet.h>
@@ -11,6 +12,7 @@
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
+#include <linux/array_size.h>
#include <linux/limits.h>
#include <linux/netlink.h>
#include <linux/random.h>
@@ -36,12 +38,12 @@
#include "../kselftest.h"
+
#define printk(fmt, ...) \
ksft_print_msg("%d[%u] " fmt "\n", getpid(), __LINE__, ##__VA_ARGS__)
#define pr_err(fmt, ...) printk(fmt ": %m", ##__VA_ARGS__)
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
#define IPV4_STR_SZ 16 /* xxx.xxx.xxx.xxx is longest + \0 */
diff --git a/tools/testing/selftests/net/reuseport_bpf.c b/tools/testing/selftests/net/reuseport_bpf.c
index b5277106df1f..c9ae6fbf69a1 100644
--- a/tools/testing/selftests/net/reuseport_bpf.c
+++ b/tools/testing/selftests/net/reuseport_bpf.c
@@ -7,9 +7,11 @@
* Additionally, a few edge cases in the implementation are tested.
*/
+
#include <errno.h>
#include <error.h>
#include <fcntl.h>
+#include <linux/array_size.h>
#include <linux/bpf.h>
#include <linux/filter.h>
#include <linux/unistd.h>
@@ -24,9 +26,6 @@
#include <sys/resource.h>
#include <unistd.h>
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-#endif
struct test_params {
int recv_family;
diff --git a/tools/testing/selftests/net/rxtimestamp.c b/tools/testing/selftests/net/rxtimestamp.c
index e4613ce4ed69..728218409225 100644
--- a/tools/testing/selftests/net/rxtimestamp.c
+++ b/tools/testing/selftests/net/rxtimestamp.c
@@ -15,10 +15,10 @@
#include <net/if.h>
#include <asm/types.h>
+#include <linux/array_size.h>
#include <linux/net_tstamp.h>
#include <linux/errqueue.h>
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
struct options {
int so_timestamp;
diff --git a/tools/testing/selftests/net/socket.c b/tools/testing/selftests/net/socket.c
index afca1ead677f..668816b5ea12 100644
--- a/tools/testing/selftests/net/socket.c
+++ b/tools/testing/selftests/net/socket.c
@@ -1,5 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
+
+
#include <stdio.h>
+#include <linux/array_size.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
@@ -7,6 +10,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
+
struct socket_testcase {
int domain;
int type;
@@ -31,7 +35,6 @@ static struct socket_testcase tests[] = {
{ AF_INET, SOCK_STREAM, IPPROTO_UDP, -EPROTONOSUPPORT, 1 },
};
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#define ERR_STRING_SZ 64
static int run_tests(void)
diff --git a/tools/testing/selftests/net/tcp_fastopen_backup_key.c b/tools/testing/selftests/net/tcp_fastopen_backup_key.c
index 9c55ec44fc43..1ece88ac587c 100644
--- a/tools/testing/selftests/net/tcp_fastopen_backup_key.c
+++ b/tools/testing/selftests/net/tcp_fastopen_backup_key.c
@@ -12,10 +12,13 @@
* there are no cases in which a cookie is not accepted by verifying
* that TcpExtTCPFastOpenPassiveFail remains 0.
*/
+
+
#define _GNU_SOURCE
#include <arpa/inet.h>
#include <errno.h>
#include <error.h>
+#include <linux/array_size.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -26,6 +29,7 @@
#include <fcntl.h>
#include <time.h>
+
#ifndef TCP_FASTOPEN_KEY
#define TCP_FASTOPEN_KEY 33
#endif
@@ -34,10 +38,6 @@
#define PROC_FASTOPEN_KEY "/proc/sys/net/ipv4/tcp_fastopen_key"
#define KEY_LENGTH 16
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-#endif
-
static bool do_ipv6;
static bool do_sockopt;
static bool do_rotate;