* [PATCH] kselftest/arm64: fix array_size.cocci warning
@ 2022-04-19 3:24 Guo Zhengkui
2022-04-19 15:55 ` Shuah Khan
2022-04-27 18:40 ` Catalin Marinas
0 siblings, 2 replies; 7+ messages in thread
From: Guo Zhengkui @ 2022-04-19 3:24 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Shuah Khan, Guo Zhengkui,
moderated list:ARM64 PORT (AARCH64 ARCHITECTURE),
open list:KERNEL SELFTEST FRAMEWORK, open list
Cc: zhengkui_guo
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(-)
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) {
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] kselftest/arm64: fix array_size.cocci warning
2022-04-19 3:24 [PATCH] kselftest/arm64: fix array_size.cocci warning Guo Zhengkui
@ 2022-04-19 15:55 ` Shuah Khan
2022-04-27 18:40 ` Catalin Marinas
1 sibling, 0 replies; 7+ messages in thread
From: Shuah Khan @ 2022-04-19 15:55 UTC (permalink / raw)
To: Guo Zhengkui, Catalin Marinas, Will Deacon, Shuah Khan,
moderated list:ARM64 PORT (AARCH64 ARCHITECTURE),
open list:KERNEL SELFTEST FRAMEWORK, open list
Cc: zhengkui_guo, Shuah Khan
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] kselftest/arm64: fix array_size.cocci warning
2022-04-19 3:24 [PATCH] kselftest/arm64: fix array_size.cocci warning Guo Zhengkui
2022-04-19 15:55 ` Shuah Khan
@ 2022-04-27 18:40 ` Catalin Marinas
1 sibling, 0 replies; 7+ messages in thread
From: Catalin Marinas @ 2022-04-27 18:40 UTC (permalink / raw)
To: open list, Shuah Khan, open list:KERNEL SELFTEST FRAMEWORK,
Will Deacon, Guo Zhengkui,
moderated list:ARM64 PORT AARCH64 ARCHITECTURE
Cc: zhengkui_guo
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
--
Catalin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] kselftest/arm64: fix array_size.cocci warning
2022-11-13 9:41 wangkailong
@ 2022-11-14 19:34 ` Will Deacon
0 siblings, 0 replies; 7+ messages in thread
From: Will Deacon @ 2022-11-14 19:34 UTC (permalink / raw)
To: catalin.marinas, shuah, wangkailong
Cc: kernel-team, Will Deacon, linux-kernel, linux-kselftest,
linux-arm-kernel
On Sun, 13 Nov 2022 17:41:10 +0800 (GMT+08:00), wangkailong@jari.cn wrote:
> Fix following coccicheck warning:
>
> tools/testing/selftests/arm64/mte/check_mmap_options.c:64:24-25:
> WARNING: Use ARRAY_SIZE
> tools/testing/selftests/arm64/mte/check_mmap_options.c:66:20-21:
> WARNING: Use ARRAY_SIZE
> tools/testing/selftests/arm64/mte/check_mmap_options.c:135:25-26:
> WARNING: Use ARRAY_SIZE
> tools/testing/selftests/arm64/mte/check_mmap_options.c:96:25-26:
> WARNING: Use ARRAY_SIZE
> tools/testing/selftests/arm64/mte/check_mmap_options.c:190:24-25:
> WARNING: Use ARRAY_SIZE
>
> [...]
Applied to arm64 (for-next/selftests), thanks!
[1/1] kselftest/arm64: fix array_size.cocci warning
https://git.kernel.org/arm64/c/a75df5be8e7b
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] kselftest/arm64: fix array_size.cocci warning
@ 2022-11-13 9:41 wangkailong
2022-11-14 19:34 ` Will Deacon
0 siblings, 1 reply; 7+ messages in thread
From: wangkailong @ 2022-11-13 9:41 UTC (permalink / raw)
To: catalin.marinas, will, shuah
Cc: linux-arm-kernel, linux-kselftest, linux-kernel
Fix following coccicheck warning:
tools/testing/selftests/arm64/mte/check_mmap_options.c:64:24-25:
WARNING: Use ARRAY_SIZE
tools/testing/selftests/arm64/mte/check_mmap_options.c:66:20-21:
WARNING: Use ARRAY_SIZE
tools/testing/selftests/arm64/mte/check_mmap_options.c:135:25-26:
WARNING: Use ARRAY_SIZE
tools/testing/selftests/arm64/mte/check_mmap_options.c:96:25-26:
WARNING: Use ARRAY_SIZE
tools/testing/selftests/arm64/mte/check_mmap_options.c:190:24-25:
WARNING: Use ARRAY_SIZE
Signed-off-by: KaiLong Wang <wangkailong@jari.cn>
---
tools/testing/selftests/arm64/mte/check_mmap_options.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/arm64/mte/check_mmap_options.c b/tools/testing/selftests/arm64/mte/check_mmap_options.c
index a04b12c21ac9..17694caaff53 100644
--- a/tools/testing/selftests/arm64/mte/check_mmap_options.c
+++ b/tools/testing/selftests/arm64/mte/check_mmap_options.c
@@ -61,9 +61,8 @@ static int check_anonymous_memory_mapping(int mem_type, int mode, int mapping, i
{
char *ptr, *map_ptr;
int run, result, map_size;
- int item = sizeof(sizes)/sizeof(int);
+ int item = ARRAY_SIZE(sizes);
- item = sizeof(sizes)/sizeof(int);
mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
for (run = 0; run < item; run++) {
map_size = sizes[run] + OVERFLOW + UNDERFLOW;
@@ -93,7 +92,7 @@ static int check_file_memory_mapping(int mem_type, int mode, int mapping, int ta
{
char *ptr, *map_ptr;
int run, fd, map_size;
- int total = sizeof(sizes)/sizeof(int);
+ int total = ARRAY_SIZE(sizes);
int result = KSFT_PASS;
mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
@@ -132,7 +131,7 @@ static int check_clear_prot_mte_flag(int mem_type, int mode, int mapping)
{
char *ptr, *map_ptr;
int run, prot_flag, result, fd, map_size;
- int total = sizeof(sizes)/sizeof(int);
+ int total = ARRAY_SIZE(sizes);
prot_flag = PROT_READ | PROT_WRITE;
mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
@@ -187,7 +186,7 @@ static int check_clear_prot_mte_flag(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);
err = mte_default_setup();
if (err)
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] kselftest/arm64: fix array_size.cocci warning
2022-11-05 7:31 Kang Minchul
@ 2022-11-08 17:38 ` Will Deacon
0 siblings, 0 replies; 7+ messages in thread
From: Will Deacon @ 2022-11-08 17:38 UTC (permalink / raw)
To: Catalin Marinas, Kang Minchul, Shuah Khan
Cc: kernel-team, Will Deacon, linux-arm-kernel, linux-kernel,
linux-kselftest
On Sat, 5 Nov 2022 16:31:43 +0900, Kang Minchul wrote:
> Use ARRAY_SIZE to fix the following coccicheck warnings:
> tools/testing/selftests/arm64/mte/check_buffer_fill.c:341:20-21:
> WARNING: Use ARRAY_SIZE
> tools/testing/selftests/arm64/mte/check_buffer_fill.c:35:20-21:
> WARNING: Use ARRAY_SIZE
> tools/testing/selftests/arm64/mte/check_buffer_fill.c:168:20-21:
> WARNING: Use ARRAY_SIZE
> tools/testing/selftests/arm64/mte/check_buffer_fill.c:72:20-21:
> WARNING: Use ARRAY_SIZE
> tools/testing/selftests/arm64/mte/check_buffer_fill.c:369:25-26:
> WARNING: Use ARRAY_SIZE
>
> [...]
Applied to arm64 (for-next/selftests), thanks!
[1/1] kselftest/arm64: fix array_size.cocci warning
https://git.kernel.org/arm64/c/a0fa0b63131b
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] kselftest/arm64: fix array_size.cocci warning
@ 2022-11-05 7:31 Kang Minchul
2022-11-08 17:38 ` Will Deacon
0 siblings, 1 reply; 7+ messages in thread
From: Kang Minchul @ 2022-11-05 7:31 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Shuah Khan
Cc: linux-arm-kernel, linux-kselftest, linux-kernel, Kang Minchul
Use ARRAY_SIZE to fix the following coccicheck warnings:
tools/testing/selftests/arm64/mte/check_buffer_fill.c:341:20-21:
WARNING: Use ARRAY_SIZE
tools/testing/selftests/arm64/mte/check_buffer_fill.c:35:20-21:
WARNING: Use ARRAY_SIZE
tools/testing/selftests/arm64/mte/check_buffer_fill.c:168:20-21:
WARNING: Use ARRAY_SIZE
tools/testing/selftests/arm64/mte/check_buffer_fill.c:72:20-21:
WARNING: Use ARRAY_SIZE
tools/testing/selftests/arm64/mte/check_buffer_fill.c:369:25-26:
WARNING: Use ARRAY_SIZE
Signed-off-by: Kang Minchul <tegongkang@gmail.com>
---
.../testing/selftests/arm64/mte/check_buffer_fill.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/arm64/mte/check_buffer_fill.c b/tools/testing/selftests/arm64/mte/check_buffer_fill.c
index 75fc482d63b6..1dbbbd47dd50 100644
--- a/tools/testing/selftests/arm64/mte/check_buffer_fill.c
+++ b/tools/testing/selftests/arm64/mte/check_buffer_fill.c
@@ -32,7 +32,7 @@ static int check_buffer_by_byte(int mem_type, int mode)
bool err;
mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
- item = sizeof(sizes)/sizeof(int);
+ item = ARRAY_SIZE(sizes);
for (i = 0; i < item; i++) {
ptr = (char *)mte_allocate_memory(sizes[i], mem_type, 0, true);
@@ -69,7 +69,7 @@ static int check_buffer_underflow_by_byte(int mem_type, int mode,
char *und_ptr = NULL;
mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
- item = sizeof(sizes)/sizeof(int);
+ item = ARRAY_SIZE(sizes);
for (i = 0; i < item; i++) {
ptr = (char *)mte_allocate_memory_tag_range(sizes[i], mem_type, 0,
underflow_range, 0);
@@ -165,7 +165,7 @@ static int check_buffer_overflow_by_byte(int mem_type, int mode,
char *over_ptr = NULL;
mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
- item = sizeof(sizes)/sizeof(int);
+ item = ARRAY_SIZE(sizes);
for (i = 0; i < item; i++) {
ptr = (char *)mte_allocate_memory_tag_range(sizes[i], mem_type, 0,
0, overflow_range);
@@ -338,7 +338,7 @@ static int check_buffer_by_block(int mem_type, int mode)
int i, item, result = KSFT_PASS;
mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
- item = sizeof(sizes)/sizeof(int);
+ item = ARRAY_SIZE(sizes);
cur_mte_cxt.fault_valid = false;
for (i = 0; i < item; i++) {
result = check_buffer_by_block_iterate(mem_type, mode, sizes[i]);
@@ -366,7 +366,7 @@ static int check_memory_initial_tags(int mem_type, int mode, int mapping)
{
char *ptr;
int run, fd;
- 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++) {
@@ -404,7 +404,7 @@ int main(int argc, char *argv[])
{
int err;
size_t page_size = getpagesize();
- int item = sizeof(sizes)/sizeof(int);
+ int item = ARRAY_SIZE(sizes);
sizes[item - 3] = page_size - 1;
sizes[item - 2] = page_size;
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-11-14 19:35 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19 3:24 [PATCH] kselftest/arm64: fix array_size.cocci warning Guo Zhengkui
2022-04-19 15:55 ` Shuah Khan
2022-04-27 18:40 ` Catalin Marinas
2022-11-05 7:31 Kang Minchul
2022-11-08 17:38 ` Will Deacon
2022-11-13 9:41 wangkailong
2022-11-14 19:34 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).