diff --git a/src/backend/pagemap.h b/src/backend/pagemap.h index 85bb113..6bb259d 100644 --- a/src/backend/pagemap.h +++ b/src/backend/pagemap.h @@ -130,7 +130,7 @@ namespace snmalloc // Put pagemap at start of range. // TODO CHERI capability bound here! - body = reinterpret_cast(b); + body = static_cast(b); body_opt = body; // Advance by size of pagemap. // Note that base needs to be aligned to GRANULARITY for the rest of the @@ -176,8 +176,7 @@ namespace snmalloc // Begin pagemap at random offset within the additionally allocated space. static_assert(bits::is_pow2(sizeof(T)), "Next line assumes this."); size_t offset = get_entropy64() & (additional_size - sizeof(T)); - auto new_body = - reinterpret_cast(pointer_offset(new_body_untyped, offset)); + auto new_body = pointer_offset(new_body_untyped, offset); if constexpr (pal_supports) { @@ -191,7 +190,7 @@ namespace snmalloc start_page, pointer_diff(start_page, end_page)); } #else - auto new_body = reinterpret_cast(new_body_untyped); + auto new_body = static_cast(new_body_untyped); #endif // Ensure bottom page is committed // ASSUME: new memory is zeroed. diff --git a/src/test/func/malloc/malloc.cc b/src/test/func/malloc/malloc.cc index 08172b3..b5bd9ff 100644 --- a/src/test/func/malloc/malloc.cc +++ b/src/test/func/malloc/malloc.cc @@ -88,16 +88,12 @@ void check_result(size_t size, size_t align, void* p, int err, bool null) expected_size); failed = true; } - if ( - (static_cast(reinterpret_cast(p) % align) != 0) && - (size != 0)) + if (((address_cast(p) % align) != 0) && (size != 0)) { INFO("Address is {}, but required to be aligned to {}.\n", p, align); failed = true; } - if ( - static_cast( - reinterpret_cast(p) % natural_alignment(size)) != 0) + if ((address_cast(p) % natural_alignment(size)) != 0) { INFO( "Address is {}, but should have natural alignment to {}.\n", diff --git a/src/test/func/memcpy/func-memcpy.cc b/src/test/func/memcpy/func-memcpy.cc index e99569e..ad8ea17 100644 --- a/src/test/func/memcpy/func-memcpy.cc +++ b/src/test/func/memcpy/func-memcpy.cc @@ -69,8 +69,8 @@ extern "C" void abort() void check_size(size_t size) { START_TEST("checking {}-byte memcpy", size); - auto* s = reinterpret_cast(my_malloc(size + 1)); - auto* d = reinterpret_cast(my_malloc(size + 1)); + auto* s = static_cast(my_malloc(size + 1)); + auto* d = static_cast(my_malloc(size + 1)); d[size] = 0; s[size] = 255; for (size_t start = 0; start < size; start++) @@ -115,8 +115,8 @@ void check_bounds(size_t size, size_t out_of_bounds) { START_TEST( "memcpy bounds, size {}, {} bytes out of bounds", size, out_of_bounds); - auto* s = reinterpret_cast(my_malloc(size)); - auto* d = reinterpret_cast(my_malloc(size)); + auto* s = static_cast(my_malloc(size)); + auto* d = static_cast(my_malloc(size)); for (size_t i = 0; i < size; ++i) { s[i] = static_cast(i); diff --git a/src/test/perf/memcpy/memcpy.cc b/src/test/perf/memcpy/memcpy.cc index b42c474..62f5da3 100644 --- a/src/test/perf/memcpy/memcpy.cc +++ b/src/test/perf/memcpy/memcpy.cc @@ -30,7 +30,7 @@ void shape(size_t size) // size / alignment) * alignment; Shape s; s.object = ThreadAlloc::get().alloc(rsize); - s.dst = reinterpret_cast(s.object) + offset; + s.dst = static_cast(s.object) + offset; // Bring into cache the destination of the copy. memset(s.dst, 0xFF, size); allocs.push_back(s); @@ -51,7 +51,7 @@ void test_memcpy(size_t size, void* src, Memcpy mc) { for (auto& s : allocs) { - auto* dst = reinterpret_cast(s.dst); + auto* dst = static_cast(s.dst); mc(dst, src, size); } }