From: Aleksa Sarai <aleksa@amutable.com>
To: Shuah Khan <shuah@kernel.org>
Cc: Christian Brauner <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org,
Aleksa Sarai <cyphar@cyphar.com>,
Aleksa Sarai <aleksa@amutable.com>
Subject: [PATCH v2 3/4] selftests: openat2: switch from custom ARRAY_LEN to ARRAY_SIZE
Date: Wed, 01 Apr 2026 11:28:04 +1100 [thread overview]
Message-ID: <20260401-openat2-selftests-kunit-v2-3-ad153a07da0c@amutable.com> (raw)
In-Reply-To: <20260401-openat2-selftests-kunit-v2-0-ad153a07da0c@amutable.com>
For whatever reason, the original version of the tests used a custom
version of ARRAY_SIZE, but ARRAY_SIZE works just as well.
Signed-off-by: Aleksa Sarai <aleksa@amutable.com>
---
tools/testing/selftests/filesystems/openat2/helpers.h | 1 -
tools/testing/selftests/filesystems/openat2/openat2_test.c | 12 ++++++------
tools/testing/selftests/filesystems/openat2/resolve_test.c | 4 ++--
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/tools/testing/selftests/filesystems/openat2/helpers.h b/tools/testing/selftests/filesystems/openat2/helpers.h
index 975de513af86..f56c0c6e3ad1 100644
--- a/tools/testing/selftests/filesystems/openat2/helpers.h
+++ b/tools/testing/selftests/filesystems/openat2/helpers.h
@@ -17,7 +17,6 @@
#include <linux/unistd.h>
#include "kselftest.h"
-#define ARRAY_LEN(X) (sizeof (X) / sizeof (*(X)))
#define BUILD_BUG_ON(e) ((void)(sizeof(struct { int:(-!!(e)); })))
/*
diff --git a/tools/testing/selftests/filesystems/openat2/openat2_test.c b/tools/testing/selftests/filesystems/openat2/openat2_test.c
index 0e161ef9e9e4..c6c26652ac1b 100644
--- a/tools/testing/selftests/filesystems/openat2/openat2_test.c
+++ b/tools/testing/selftests/filesystems/openat2/openat2_test.c
@@ -83,14 +83,14 @@ void test_openat2_struct(void)
.size = sizeof(struct open_how_ext), .err = -E2BIG },
};
- BUILD_BUG_ON(ARRAY_LEN(misalignments) != NUM_OPENAT2_STRUCT_VARIATIONS);
- BUILD_BUG_ON(ARRAY_LEN(tests) != NUM_OPENAT2_STRUCT_TESTS);
+ BUILD_BUG_ON(ARRAY_SIZE(misalignments) != NUM_OPENAT2_STRUCT_VARIATIONS);
+ BUILD_BUG_ON(ARRAY_SIZE(tests) != NUM_OPENAT2_STRUCT_TESTS);
- for (int i = 0; i < ARRAY_LEN(tests); i++) {
+ for (int i = 0; i < ARRAY_SIZE(tests); i++) {
struct struct_test *test = &tests[i];
struct open_how_ext how_ext = test->arg;
- for (int j = 0; j < ARRAY_LEN(misalignments); j++) {
+ for (int j = 0; j < ARRAY_SIZE(misalignments); j++) {
int fd, misalign = misalignments[j];
char *fdpath = NULL;
bool failed;
@@ -241,9 +241,9 @@ void test_openat2_flags(void)
.how.resolve = 0, .err = -EINVAL },
};
- BUILD_BUG_ON(ARRAY_LEN(tests) != NUM_OPENAT2_FLAG_TESTS);
+ BUILD_BUG_ON(ARRAY_SIZE(tests) != NUM_OPENAT2_FLAG_TESTS);
- for (int i = 0; i < ARRAY_LEN(tests); i++) {
+ for (int i = 0; i < ARRAY_SIZE(tests); i++) {
int fd, fdflags = -1;
char *path, *fdpath = NULL;
bool failed = false;
diff --git a/tools/testing/selftests/filesystems/openat2/resolve_test.c b/tools/testing/selftests/filesystems/openat2/resolve_test.c
index a76ef15ceb90..f7acb4300641 100644
--- a/tools/testing/selftests/filesystems/openat2/resolve_test.c
+++ b/tools/testing/selftests/filesystems/openat2/resolve_test.c
@@ -436,9 +436,9 @@ void test_openat2_opath_tests(void)
.out.err = -ELOOP, .pass = false },
};
- BUILD_BUG_ON(ARRAY_LEN(tests) != NUM_OPENAT2_OPATH_TESTS);
+ BUILD_BUG_ON(ARRAY_SIZE(tests) != NUM_OPENAT2_OPATH_TESTS);
- for (int i = 0; i < ARRAY_LEN(tests); i++) {
+ for (int i = 0; i < ARRAY_SIZE(tests); i++) {
int dfd, fd;
char *fdpath = NULL;
bool failed;
--
2.53.0
next prev parent reply other threads:[~2026-04-01 0:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 0:28 [PATCH v2 0/4] selftests: openat2: migrate to kselftest harness Aleksa Sarai
2026-04-01 0:28 ` [PATCH v2 1/4] selftests: move openat2 tests to selftests/filesystems/ Aleksa Sarai
2026-04-01 0:28 ` [PATCH v2 2/4] selftests: openat2: move helpers to header Aleksa Sarai
2026-04-01 0:28 ` Aleksa Sarai [this message]
2026-04-01 0:28 ` [PATCH v2 4/4] selftests: openat2: migrate to kselftest harness Aleksa Sarai
2026-04-09 13:30 ` [PATCH v2 0/4] " Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260401-openat2-selftests-kunit-v2-3-ad153a07da0c@amutable.com \
--to=aleksa@amutable.com \
--cc=brauner@kernel.org \
--cc=cyphar@cyphar.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox