[compiler-rt] 4a69e0a - [test][hwasan] Rename constants in test
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 14 01:00:49 PDT 2023
Author: Vitaly Buka
Date: 2023-06-14T01:00:35-07:00
New Revision: 4a69e0a0ad2fd3fb3ec590a9db4ac5390c7093e7
URL: https://github.com/llvm/llvm-project/commit/4a69e0a0ad2fd3fb3ec590a9db4ac5390c7093e7
DIFF: https://github.com/llvm/llvm-project/commit/4a69e0a0ad2fd3fb3ec590a9db4ac5390c7093e7.diff
LOG: [test][hwasan] Rename constants in test
Added:
Modified:
compiler-rt/test/hwasan/TestCases/munmap.c
Removed:
################################################################################
diff --git a/compiler-rt/test/hwasan/TestCases/munmap.c b/compiler-rt/test/hwasan/TestCases/munmap.c
index 3c4ffde3c27ad..f25e488e4698c 100644
--- a/compiler-rt/test/hwasan/TestCases/munmap.c
+++ b/compiler-rt/test/hwasan/TestCases/munmap.c
@@ -9,13 +9,12 @@
#include <sys/mman.h>
int main(int argc, char **argv) {
- int size = 4096;
- int tag = 74;
- int val = 42;
+ const int kSize = 4096;
+ const int kTag = 74;
// Get any mmaped pointer.
void *r =
- mmap(0, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
+ mmap(0, kSize, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
if (r == MAP_FAILED) {
fprintf(stderr, "Failed to mmap.\n");
abort();
@@ -28,23 +27,23 @@ int main(int argc, char **argv) {
}
// Manually tag the pointer and the memory.
- __hwasan_tag_memory(r, tag, size);
- int *p1 = __hwasan_tag_pointer(r, tag);
+ __hwasan_tag_memory(r, kTag, kSize);
+ int *p1 = __hwasan_tag_pointer(r, kTag);
// Check that the pointer and the tag match.
- if (__hwasan_test_shadow(p1, size) != -1) {
+ if (__hwasan_test_shadow(p1, kSize) != -1) {
fprintf(stderr, "Failed to tag.\n");
return 1;
}
// First munmmap and then mmap the same pointer using MAP_FIXED.
- munmap(r, size);
- if (__hwasan_test_shadow(r, size) != -1) {
+ munmap(r, kSize);
+ if (__hwasan_test_shadow(r, kSize) != -1) {
fprintf(stderr, "Shadow memory was not cleaned by munmap.\n");
return 1;
}
- __hwasan_tag_memory(r, tag, size);
- int *p2 = (int *)mmap(r, size, PROT_READ | PROT_WRITE,
+ __hwasan_tag_memory(r, kTag, kSize);
+ int *p2 = (int *)mmap(r, kSize, PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0);
// Check that the pointer has no tag in it.
@@ -54,7 +53,7 @@ int main(int argc, char **argv) {
}
// Make sure we can access the shadow with an untagged pointer.
- if (__hwasan_test_shadow(p2, size) != -1 ) {
+ if (__hwasan_test_shadow(p2, kSize) != -1) {
fprintf(stderr, "Shadow memory was not cleaned by mmap.\n");
return 1;
}
More information about the llvm-commits
mailing list