selftests/net: replace manual array size calc with ARRAYSIZE macro.
Subsystems (3)
PATCH v2 1/1 selftests/net: replace manual array size calc with ARRAYSIZE macro.
fixes coccinelle WARNING: Use ARRAY_SIZE
changelog since v1:
- remove unnecessary extra new line
changelog since v0:
- update net/Makefile to include kselftest.h
- remove redefinition of ARRAYSIZE.
Signed-off-by Mahmoud Maatuq <[email protected]>
--- tools/testing/selftests/net/Makefile | 2 ++ tools/testing/selftests/net/csum.c | 6 ++---- tools/testing/selftests/net/hwtstamp_config.c | 4 +--- 3 files changed, 5 insertions(+), 7 deletions(-)
tools/testing/selftests/net/Makefile +2 -0
@@ -3,6 +3,8 @@ CFLAGS = -Wall -Wl,--no-as-needed -O2 -g CFLAGS += -I../../../../usr/include/ $(KHDR_INCLUDES) +# Additional include paths needed by kselftest.h +CFLAGS += -I../ TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh \ rtnetlink.sh xfrm_policy.sh test_blackhole_dev.sh
tools/testing/selftests/net/csum.c +2 -4
@@ -91,6 +91,8 @@#include <sys/types.h> #include <unistd.h> +#include "kselftest.h" +static bool cfg_bad_csum;static int cfg_family =PF_INET6 ;static int cfg_num_pkt =4 ;
@@ -123,10 +125,6 @@ static struct sockaddr_in6 cfg_saddr6 = {.sin6_family = AF_INET6};#define MAX_HEADER_LEN (sizeof(struct ipv6hdr) + ENC_HEADER_LEN + sizeof(struct tcphdr))#define MAX_PAYLOAD_LEN 1024 -#ifndef ARRAY_SIZE -#define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0])) -#endif -/* Trivial demo encap. Stand-in for transport layer protocols like ESP or PSP */ struct udp_encap_hdr {uint8_t nexthdr;
tools/testing/selftests/net/hwtstamp_config.c +1 -3
@@ -16,9 +16,7 @@#include <linux/net_tstamp.h> #include <linux/sockios.h> -#ifndef ARRAY_SIZE -#define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0])) -#endif +#include "kselftest.h" static int lookup_value (const char **names,int size,const char *name)
Signature · 1 line
2.34.1