Skip to content

Commit a0fa0b6

Browse files
kangtegongwilldeacon
authored andcommitted
kselftest/arm64: fix array_size.cocci warning
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 9b28388 commit a0fa0b6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tools/testing/selftests/arm64/mte/check_buffer_fill.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static int check_buffer_by_byte(int mem_type, int mode)
3232
bool err;
3333

3434
mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
35-
item = sizeof(sizes)/sizeof(int);
35+
item = ARRAY_SIZE(sizes);
3636

3737
for (i = 0; i < item; i++) {
3838
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,
6969
char *und_ptr = NULL;
7070

7171
mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
72-
item = sizeof(sizes)/sizeof(int);
72+
item = ARRAY_SIZE(sizes);
7373
for (i = 0; i < item; i++) {
7474
ptr = (char *)mte_allocate_memory_tag_range(sizes[i], mem_type, 0,
7575
underflow_range, 0);
@@ -165,7 +165,7 @@ static int check_buffer_overflow_by_byte(int mem_type, int mode,
165165
char *over_ptr = NULL;
166166

167167
mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
168-
item = sizeof(sizes)/sizeof(int);
168+
item = ARRAY_SIZE(sizes);
169169
for (i = 0; i < item; i++) {
170170
ptr = (char *)mte_allocate_memory_tag_range(sizes[i], mem_type, 0,
171171
0, overflow_range);
@@ -338,7 +338,7 @@ static int check_buffer_by_block(int mem_type, int mode)
338338
int i, item, result = KSFT_PASS;
339339

340340
mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
341-
item = sizeof(sizes)/sizeof(int);
341+
item = ARRAY_SIZE(sizes);
342342
cur_mte_cxt.fault_valid = false;
343343
for (i = 0; i < item; i++) {
344344
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)
366366
{
367367
char *ptr;
368368
int run, fd;
369-
int total = sizeof(sizes)/sizeof(int);
369+
int total = ARRAY_SIZE(sizes);
370370

371371
mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
372372
for (run = 0; run < total; run++) {
@@ -404,7 +404,7 @@ int main(int argc, char *argv[])
404404
{
405405
int err;
406406
size_t page_size = getpagesize();
407-
int item = sizeof(sizes)/sizeof(int);
407+
int item = ARRAY_SIZE(sizes);
408408

409409
sizes[item - 3] = page_size - 1;
410410
sizes[item - 2] = page_size;

0 commit comments

Comments
 (0)