Skip to content

Commit ebaf748

Browse files
Rob Lyerlymeta-codesync[bot]
authored andcommitted
Fix lints in SlabAllocator
Summary: Fix a few lints: - pointer->integer->pointer round trip limits compiler provenance tracking and reduces optimization opportunities - unused value - unused header Reviewed By: IvanTopolcic Differential Revision: D90204773 fbshipit-source-id: ea94fc54d8300adb06b47bc401164d484494d894
1 parent 16b619a commit ebaf748

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

cachelib/allocator/memory/SlabAllocator.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <sys/mman.h>
2424

2525
#include <chrono>
26-
#include <memory>
2726
#include <stdexcept>
2827

2928
#include "cachelib/common/Utils.h"
@@ -341,7 +340,7 @@ Slab* SlabAllocator::makeNewSlabImpl() {
341340
void SlabAllocator::initializeHeader(Slab* slab, PoolId id) {
342341
auto* header = getSlabHeader(slab);
343342
XDCHECK(header != nullptr);
344-
header = new (header) SlabHeader(id);
343+
new (header) SlabHeader(id);
345344
}
346345

347346
Slab* SlabAllocator::makeNewSlab(PoolId id) {
@@ -461,8 +460,8 @@ std::tuple<uint32_t, const void*> SlabAllocator::getRandomAlloc()
461460

462461
// pick a random location in the memory.
463462
const auto offset = folly::Random::rand64(0, validMaxOffset);
464-
const auto* memory = reinterpret_cast<void*>(
465-
reinterpret_cast<uintptr_t>(slabMemoryStart_) + offset);
463+
const auto* memory =
464+
reinterpret_cast<const uint8_t*>(slabMemoryStart_) + offset;
466465

467466
const auto* slab = getSlabForMemory(memory);
468467
const auto* header = getSlabHeader(slab);
@@ -484,8 +483,7 @@ std::tuple<uint32_t, const void*> SlabAllocator::getRandomAlloc()
484483
allocSize;
485484
allocIdx = allocIdx > maxAllocIdx ? maxAllocIdx : allocIdx;
486485
return std::make_tuple(
487-
allocSize, reinterpret_cast<const void*>(
488-
reinterpret_cast<uintptr_t>(slab) + allocSize * allocIdx));
486+
allocSize, reinterpret_cast<const uint8_t*>(slab) + allocSize * allocIdx);
489487
}
490488

491489
serialization::SlabAllocatorObject SlabAllocator::saveState() {

0 commit comments

Comments
 (0)