diff mbox series

[v1,2/2] selftests/mm: fix coccinelle WARNING recommending the use of ARRAY_SIZE()

Message ID 20241101111523.1293193-4-mtodorovac69@gmail.com (mailing list archive)
State New
Headers show
Series [v1,1/2] selftests/x86/syscall: fix coccinelle WARNING recommending the use of ARRAY_SIZE() | expand

Commit Message

Mirsad Todorovac Nov. 1, 2024, 11:15 a.m. UTC
Coccinelle gives WARNING recommending the use of ARRAY_SIZE() macro definition
to improve the code readability:

./tools/testing/selftests/mm/uffd-unit-tests.c:1484:32-33: WARNING: Use ARRAY_SIZE
./tools/testing/selftests/mm/uffd-unit-tests.c:1485:30-31: WARNING: Use ARRAY_SIZE

Fixes: 16a45b57cbf2 ("selftests/mm: add framework for uffd-unit-test")
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: linux-mm@kvack.org
Cc: linux-kselftest@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Mirsad Todorovac <mtodorovac69@gmail.com>
---
 v1: initial version.

 tools/testing/selftests/mm/uffd-unit-tests.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Peter Xu Nov. 1, 2024, 1:48 p.m. UTC | #1
On Fri, Nov 01, 2024 at 12:15:25PM +0100, Mirsad Todorovac wrote:
> Coccinelle gives WARNING recommending the use of ARRAY_SIZE() macro definition
> to improve the code readability:
> 
> ./tools/testing/selftests/mm/uffd-unit-tests.c:1484:32-33: WARNING: Use ARRAY_SIZE
> ./tools/testing/selftests/mm/uffd-unit-tests.c:1485:30-31: WARNING: Use ARRAY_SIZE
> 
> Fixes: 16a45b57cbf2 ("selftests/mm: add framework for uffd-unit-test")
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Shuah Khan <shuah@kernel.org>
> Cc: Peter Xu <peterx@redhat.com>
> Cc: linux-mm@kvack.org
> Cc: linux-kselftest@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Mirsad Todorovac <mtodorovac69@gmail.com>

Acked-by: Peter Xu <peterx@redhat.com>
Mirsad Todorovac Nov. 2, 2024, 6:53 p.m. UTC | #2
On 11/1/24 14:48, Peter Xu wrote:
> On Fri, Nov 01, 2024 at 12:15:25PM +0100, Mirsad Todorovac wrote:
>> Coccinelle gives WARNING recommending the use of ARRAY_SIZE() macro definition
>> to improve the code readability:
>>
>> ./tools/testing/selftests/mm/uffd-unit-tests.c:1484:32-33: WARNING: Use ARRAY_SIZE
>> ./tools/testing/selftests/mm/uffd-unit-tests.c:1485:30-31: WARNING: Use ARRAY_SIZE
>>
>> Fixes: 16a45b57cbf2 ("selftests/mm: add framework for uffd-unit-test")
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: Shuah Khan <shuah@kernel.org>
>> Cc: Peter Xu <peterx@redhat.com>
>> Cc: linux-mm@kvack.org
>> Cc: linux-kselftest@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> Signed-off-by: Mirsad Todorovac <mtodorovac69@gmail.com>
> 
> Acked-by: Peter Xu <peterx@redhat.com>

Thanks for the quick review.

Best regards,
Mirsad
diff mbox series

Patch

diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c
index a2e71b1636e7..4f6a7440a9aa 100644
--- a/tools/testing/selftests/mm/uffd-unit-tests.c
+++ b/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -1481,8 +1481,8 @@  static void usage(const char *prog)
 
 int main(int argc, char *argv[])
 {
-	int n_tests = sizeof(uffd_tests) / sizeof(uffd_test_case_t);
-	int n_mems = sizeof(mem_types) / sizeof(mem_type_t);
+	int n_tests = ARRAY_SIZE(uffd_tests);
+	int n_mems = ARRAY_SIZE(mem_types);
 	const char *test_filter = NULL;
 	bool list_only = false;
 	uffd_test_case_t *test;