]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests: openat2: switch from custom ARRAY_LEN to ARRAY_SIZE
authorAleksa Sarai <aleksa@amutable.com>
Wed, 1 Apr 2026 00:28:04 +0000 (11:28 +1100)
committerChristian Brauner <brauner@kernel.org>
Thu, 21 May 2026 08:53:25 +0000 (10:53 +0200)
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>
Link: https://patch.msgid.link/20260401-openat2-selftests-kunit-v2-3-ad153a07da0c@amutable.com
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
tools/testing/selftests/filesystems/openat2/helpers.h
tools/testing/selftests/filesystems/openat2/openat2_test.c
tools/testing/selftests/filesystems/openat2/resolve_test.c

index 975de513af8642b0c8df2350a5b751699ff01dcc..f56c0c6e3ad15a1b81e5a456aed00866a90eb637 100644 (file)
@@ -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)); })))
 
 /*
index 0e161ef9e9e4871ab01710d26ad9a23c77d541b2..c6c26652ac1b7e9985b29fd23a4203caec269c1e 100644 (file)
@@ -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;
index a76ef15ceb90aeef3b8c2475a2e0e2dda25be271..f7acb430064160c02479ac3aa318386858a8f843 100644 (file)
@@ -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;