* [PATCH v1] selftests/net: replace manual array size calc with ARRAYSIZE macro.
@ 2023-07-14 19:46 Mahmoud Maatuq
2023-07-14 19:52 ` Jakub Kicinski
0 siblings, 1 reply; 2+ messages in thread
From: Mahmoud Maatuq @ 2023-07-14 19:46 UTC (permalink / raw)
To: shuah; +Cc: linux-kselftest, davem, kuba, linux-kernel-mentees,
Mahmoud Maatuq
fixes coccinelle WARNING: Use ARRAY_SIZE
changelog since v0:
- update net/Makefile to include kselftest.h
- remove redefinition of ARRAYSIZE.
Signed-off-by: Mahmoud Maatuq <mahmoudmatook.mm@gmail.com>
---
tools/testing/selftests/net/Makefile | 2 ++
tools/testing/selftests/net/csum.c | 6 ++----
tools/testing/selftests/net/hwtstamp_config.c | 5 ++---
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 7f3ab2a93ed6..a06cc25489f9 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -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
diff --git a/tools/testing/selftests/net/csum.c b/tools/testing/selftests/net/csum.c
index 702f34a9d506..90eb06fefa59 100644
--- a/tools/testing/selftests/net/csum.c
+++ b/tools/testing/selftests/net/csum.c
@@ -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;
diff --git a/tools/testing/selftests/net/hwtstamp_config.c b/tools/testing/selftests/net/hwtstamp_config.c
index 263cc1c34165..873f4937f37f 100644
--- a/tools/testing/selftests/net/hwtstamp_config.c
+++ b/tools/testing/selftests/net/hwtstamp_config.c
@@ -16,9 +16,8 @@
#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)
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] selftests/net: replace manual array size calc with ARRAYSIZE macro.
2023-07-14 19:46 [PATCH v1] selftests/net: replace manual array size calc with ARRAYSIZE macro Mahmoud Maatuq
@ 2023-07-14 19:52 ` Jakub Kicinski
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2023-07-14 19:52 UTC (permalink / raw)
To: Mahmoud Maatuq; +Cc: shuah, linux-kselftest, davem, linux-kernel-mentees
On Fri, 14 Jul 2023 23:46:35 +0400 Mahmoud Maatuq wrote:
> diff --git a/tools/testing/selftests/net/hwtstamp_config.c b/tools/testing/selftests/net/hwtstamp_config.c
Please resend and CC netdev@
There's ongoing work on hwtstamp configuration, there may be a conflict
if this goes via the general selftest tree.
> index 263cc1c34165..873f4937f37f 100644
> --- a/tools/testing/selftests/net/hwtstamp_config.c
> +++ b/tools/testing/selftests/net/hwtstamp_config.c
> @@ -16,9 +16,8 @@
> #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"
> +
>
unnecessary extra new line
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-14 19:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-14 19:46 [PATCH v1] selftests/net: replace manual array size calc with ARRAYSIZE macro Mahmoud Maatuq
2023-07-14 19:52 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox