diff mbox series

kselftest/arm64: fix array_size.cocci warning

Message ID 20220419032501.22790-1-guozhengkui@vivo.com (mailing list archive)
State Accepted
Commit f82efe5b9a3ae75a557097a074b0125032e76a83
Headers show
Series kselftest/arm64: fix array_size.cocci warning | expand

Commit Message

Guo Zhengkui April 19, 2022, 3:24 a.m. UTC
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>
---
 tools/testing/selftests/arm64/mte/check_child_memory.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Shuah Khan April 19, 2022, 3:55 p.m. UTC | #1
On 4/18/22 9:24 PM, Guo Zhengkui wrote:
> 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>

Looks good to me.

Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah
Catalin Marinas April 27, 2022, 6:40 p.m. UTC | #2
On Tue, 19 Apr 2022 11:24:51 +0800, Guo Zhengkui wrote:
> 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
> 
> [...]

Applied to arm64 (for-next/kselftest), thanks!

[1/1] kselftest/arm64: fix array_size.cocci warning
      https://git.kernel.org/arm64/c/55a5c18e5dab
diff mbox series

Patch

diff --git a/tools/testing/selftests/arm64/mte/check_child_memory.c b/tools/testing/selftests/arm64/mte/check_child_memory.c
index 43bd94f853ba..7597fc632cad 100644
--- a/tools/testing/selftests/arm64/mte/check_child_memory.c
+++ b/tools/testing/selftests/arm64/mte/check_child_memory.c
@@ -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) {