[PATCH] selftests/net: use ARRAY_SIZE macro in skf_net_off.c

From: longlong yan

Date: Fri Jul 17 2026 - 02:26:19 EST


The ARRAY_SIZE macro is more compact and more formal in linux source.

Fixes: fcd7132cb1f9 ("selftests/net: test sk_filter support for SKF_NET_OFF on frags")
Signed-off-by: longlong yan <yanlonglong@xxxxxxxxxx>
---
tools/testing/selftests/net/skf_net_off.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/net/skf_net_off.c b/tools/testing/selftests/net/skf_net_off.c
index 1fdf61d6cd7f..d4e38d326c39 100644
--- a/tools/testing/selftests/net/skf_net_off.c
+++ b/tools/testing/selftests/net/skf_net_off.c
@@ -46,6 +46,7 @@
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
+#include "kselftest.h"

static bool cfg_do_filter;
static bool cfg_do_frags;
@@ -92,7 +93,7 @@ static void sk_set_filter(int fd)
};

struct sock_fprog filter = {
- sizeof(filter_code) / sizeof(filter_code[0]),
+ ARRAY_SIZE(filter_code),
filter_code,
};

@@ -159,7 +160,7 @@ static void tun_write(int fd)
iov[4].iov_base = &payload;
iov[4].iov_len = sizeof(payload);

- ret = writev(fd, iov, sizeof(iov) / sizeof(iov[0]));
+ ret = writev(fd, iov, ARRAY_SIZE(iov));
if (ret <= 0)
error(1, errno, "writev");
}
@@ -183,7 +184,7 @@ static void raw_read(int fd)
iov[1].iov_len = sizeof(payload);

msg.msg_iov = iov;
- msg.msg_iovlen = sizeof(iov) / sizeof(iov[0]);
+ msg.msg_iovlen = ARRAY_SIZE(iov);

ret = recvmsg(fd, &msg, 0);
if (ret <= 0)
--
2.43.0