kselftest/arm64: fix array_size.cocci warning
authorGuo Zhengkui <guozhengkui@vivo.com>
Tue, 19 Apr 2022 03:24:51 +0000 (11:24 +0800)
committerCatalin Marinas <catalin.marinas@arm.com>
Thu, 28 Apr 2022 16:57:13 +0000 (17:57 +0100)
Fix the following coccicheck warnings:
tools/testing/selftests/arm64/mte/check_child_memory.c:110:25-26:
WARNING: Use ARRAY_SIZE
tools/testing/selftests/arm64/mte/check_child_memory.c:88:24-25:
WARNING: Use ARRAY_SIZE
tools/testing/selftests/arm64/mte/check_child_memory.c:90:20-21:
WARNING: Use ARRAY_SIZE
tools/testing/selftests/arm64/mte/check_child_memory.c:147:24-25:
WARNING: Use ARRAY_SIZE

`ARRAY_SIZE` macro is defined in tools/testing/selftests/kselftest.h.

Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20220419032501.22790-1-guozhengkui@vivo.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
tools/testing/selftests/arm64/mte/check_child_memory.c

index 43bd94f853ba70a59e974ebcecbb0ab11d6b6ef8..7597fc632cadf287b72e5cbe744501a619ad61f4 100644 (file)
@@ -85,9 +85,9 @@ static int check_child_memory_mapping(int mem_type, int mode, int mapping)
 {
        char *ptr;
        int run, result;
-       int item = sizeof(sizes)/sizeof(int);
+       int item = ARRAY_SIZE(sizes);
 
-       item = sizeof(sizes)/sizeof(int);
+       item = ARRAY_SIZE(sizes);
        mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
        for (run = 0; run < item; run++) {
                ptr = (char *)mte_allocate_memory_tag_range(sizes[run], mem_type, mapping,
@@ -107,7 +107,7 @@ static int check_child_file_mapping(int mem_type, int mode, int mapping)
 {
        char *ptr, *map_ptr;
        int run, fd, map_size, result = KSFT_PASS;
-       int total = sizeof(sizes)/sizeof(int);
+       int total = ARRAY_SIZE(sizes);
 
        mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
        for (run = 0; run < total; run++) {
@@ -144,7 +144,7 @@ static int check_child_file_mapping(int mem_type, int mode, int mapping)
 int main(int argc, char *argv[])
 {
        int err;
-       int item = sizeof(sizes)/sizeof(int);
+       int item = ARRAY_SIZE(sizes);
 
        page_size = getpagesize();
        if (!page_size) {