Fix the remaining clang-tidy warnings.
This introduces a new `address_t` type and two new casts: `pointer_cast` and `address_cast` for casting between an `address_t` and a pointer. These should make it easier to audit the codebase for casts between pointers and integers. In particular, the remaining `reinterpret_cast`s and `pointer_cast`s should be the only places where we could perform invalid pointer arithmetic. Also adds a `pointer_offset` helper that adds an offset (in bytes) to a pointer, preserving its original type. This is a sufficiently common pattern that it seemed worthwhile to centralise it.
This commit is contained in:
@@ -82,7 +82,8 @@ namespace snmalloc
|
||||
|
||||
if (slab_count.current != 0)
|
||||
{
|
||||
double occupancy = (double)count.current / (double)slab_count.current;
|
||||
double occupancy = static_cast<double>(count.current) /
|
||||
static_cast<double>(slab_count.current);
|
||||
uint64_t duration = now - time;
|
||||
|
||||
if (ticks == 0)
|
||||
@@ -103,7 +104,7 @@ namespace snmalloc
|
||||
// Keep in sync with header lower down
|
||||
count.print(csv, multiplier);
|
||||
slab_count.print(csv, slab_multiplier);
|
||||
size_t average = (size_t)(online_average * multiplier);
|
||||
size_t average = static_cast<size_t>(online_average * multiplier);
|
||||
|
||||
csv << average << (slab_multiplier - average) * slab_count.max
|
||||
<< csv.endl;
|
||||
|
||||
Reference in New Issue
Block a user