Skip to content

Commit 541235d

Browse files
brooniectmarinas
authored andcommitted
selftests/arm64: Remove casts to/from void in check_tags_inclusion
Void pointers may be freely used with other pointer types in C, any casts between void * and other pointer types serve no purpose other than to mask potential warnings. Drop such casts from check_tags_inclusion to help with future review of the code. Signed-off-by: Mark Brown <[email protected]> Reviewed-by: Shuah Khan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 72d6771 commit 541235d

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static int verify_mte_pointer_validity(char *ptr, int mode)
2323
{
2424
mte_initialize_current_context(mode, (uintptr_t)ptr, BUFFER_SIZE);
2525
/* Check the validity of the tagged pointer */
26-
memset((void *)ptr, '1', BUFFER_SIZE);
26+
memset(ptr, '1', BUFFER_SIZE);
2727
mte_wait_after_trig();
2828
if (cur_mte_cxt.fault_valid) {
2929
ksft_print_msg("Unexpected fault recorded for %p-%p in mode %x\n",
@@ -51,7 +51,7 @@ static int check_single_included_tags(int mem_type, int mode)
5151
char *ptr;
5252
int tag, run, ret, result = KSFT_PASS;
5353

54-
ptr = (char *)mte_allocate_memory(BUFFER_SIZE + MT_GRANULE_SIZE, mem_type, 0, false);
54+
ptr = mte_allocate_memory(BUFFER_SIZE + MT_GRANULE_SIZE, mem_type, 0, false);
5555
if (check_allocated_memory(ptr, BUFFER_SIZE + MT_GRANULE_SIZE,
5656
mem_type, false) != KSFT_PASS)
5757
return KSFT_FAIL;
@@ -62,7 +62,7 @@ static int check_single_included_tags(int mem_type, int mode)
6262
result = KSFT_FAIL;
6363
/* Try to catch a excluded tag by a number of tries. */
6464
for (run = 0; (run < RUNS) && (result == KSFT_PASS); run++) {
65-
ptr = (char *)mte_insert_tags(ptr, BUFFER_SIZE);
65+
ptr = mte_insert_tags(ptr, BUFFER_SIZE);
6666
/* Check tag value */
6767
if (MT_FETCH_TAG((uintptr_t)ptr) == tag) {
6868
ksft_print_msg("FAIL: wrong tag = 0x%x with include mask=0x%x\n",
@@ -74,7 +74,7 @@ static int check_single_included_tags(int mem_type, int mode)
7474
result = verify_mte_pointer_validity(ptr, mode);
7575
}
7676
}
77-
mte_free_memory_tag_range((void *)ptr, BUFFER_SIZE, mem_type, 0, MT_GRANULE_SIZE);
77+
mte_free_memory_tag_range(ptr, BUFFER_SIZE, mem_type, 0, MT_GRANULE_SIZE);
7878
return result;
7979
}
8080

@@ -84,7 +84,7 @@ static int check_multiple_included_tags(int mem_type, int mode)
8484
int tag, run, result = KSFT_PASS;
8585
unsigned long excl_mask = 0;
8686

87-
ptr = (char *)mte_allocate_memory(BUFFER_SIZE + MT_GRANULE_SIZE, mem_type, 0, false);
87+
ptr = mte_allocate_memory(BUFFER_SIZE + MT_GRANULE_SIZE, mem_type, 0, false);
8888
if (check_allocated_memory(ptr, BUFFER_SIZE + MT_GRANULE_SIZE,
8989
mem_type, false) != KSFT_PASS)
9090
return KSFT_FAIL;
@@ -94,7 +94,7 @@ static int check_multiple_included_tags(int mem_type, int mode)
9494
mte_switch_mode(mode, MT_INCLUDE_VALID_TAGS(excl_mask));
9595
/* Try to catch a excluded tag by a number of tries. */
9696
for (run = 0; (run < RUNS) && (result == KSFT_PASS); run++) {
97-
ptr = (char *)mte_insert_tags(ptr, BUFFER_SIZE);
97+
ptr = mte_insert_tags(ptr, BUFFER_SIZE);
9898
/* Check tag value */
9999
if (MT_FETCH_TAG((uintptr_t)ptr) < tag) {
100100
ksft_print_msg("FAIL: wrong tag = 0x%x with include mask=0x%x\n",
@@ -106,7 +106,7 @@ static int check_multiple_included_tags(int mem_type, int mode)
106106
result = verify_mte_pointer_validity(ptr, mode);
107107
}
108108
}
109-
mte_free_memory_tag_range((void *)ptr, BUFFER_SIZE, mem_type, 0, MT_GRANULE_SIZE);
109+
mte_free_memory_tag_range(ptr, BUFFER_SIZE, mem_type, 0, MT_GRANULE_SIZE);
110110
return result;
111111
}
112112

@@ -115,7 +115,7 @@ static int check_all_included_tags(int mem_type, int mode)
115115
char *ptr;
116116
int run, ret, result = KSFT_PASS;
117117

118-
ptr = (char *)mte_allocate_memory(BUFFER_SIZE + MT_GRANULE_SIZE, mem_type, 0, false);
118+
ptr = mte_allocate_memory(BUFFER_SIZE + MT_GRANULE_SIZE, mem_type, 0, false);
119119
if (check_allocated_memory(ptr, BUFFER_SIZE + MT_GRANULE_SIZE,
120120
mem_type, false) != KSFT_PASS)
121121
return KSFT_FAIL;
@@ -132,7 +132,7 @@ static int check_all_included_tags(int mem_type, int mode)
132132
*/
133133
result = verify_mte_pointer_validity(ptr, mode);
134134
}
135-
mte_free_memory_tag_range((void *)ptr, BUFFER_SIZE, mem_type, 0, MT_GRANULE_SIZE);
135+
mte_free_memory_tag_range(ptr, BUFFER_SIZE, mem_type, 0, MT_GRANULE_SIZE);
136136
return result;
137137
}
138138

@@ -141,7 +141,7 @@ static int check_none_included_tags(int mem_type, int mode)
141141
char *ptr;
142142
int run, ret;
143143

144-
ptr = (char *)mte_allocate_memory(BUFFER_SIZE, mem_type, 0, false);
144+
ptr = mte_allocate_memory(BUFFER_SIZE, mem_type, 0, false);
145145
if (check_allocated_memory(ptr, BUFFER_SIZE, mem_type, false) != KSFT_PASS)
146146
return KSFT_FAIL;
147147

@@ -159,12 +159,12 @@ static int check_none_included_tags(int mem_type, int mode)
159159
}
160160
mte_initialize_current_context(mode, (uintptr_t)ptr, BUFFER_SIZE);
161161
/* Check the write validity of the untagged pointer */
162-
memset((void *)ptr, '1', BUFFER_SIZE);
162+
memset(ptr, '1', BUFFER_SIZE);
163163
mte_wait_after_trig();
164164
if (cur_mte_cxt.fault_valid)
165165
break;
166166
}
167-
mte_free_memory((void *)ptr, BUFFER_SIZE, mem_type, false);
167+
mte_free_memory(ptr, BUFFER_SIZE, mem_type, false);
168168
if (cur_mte_cxt.fault_valid)
169169
return KSFT_FAIL;
170170
else

0 commit comments

Comments
 (0)