From 187a016c39930e6b02e859b1849b1f33c31486eb Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Mon, 1 Jul 2019 13:10:57 +0100 Subject: [PATCH] Clang Tidy and Warnings --- src/mem/alloc.h | 2 ++ src/mem/sizeclasstable.h | 4 +++- src/mem/slab.h | 7 ++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/mem/alloc.h b/src/mem/alloc.h index 7e8d402..acf6277 100644 --- a/src/mem/alloc.h +++ b/src/mem/alloc.h @@ -235,6 +235,8 @@ namespace snmalloc { protected: FreeListHead small_fast_free_lists[NUM_SMALL_CLASSES]; + public: + FastFreeLists () : small_fast_free_lists() {} }; /** diff --git a/src/mem/sizeclasstable.h b/src/mem/sizeclasstable.h index 6ecab99..d4fc1ee 100644 --- a/src/mem/sizeclasstable.h +++ b/src/mem/sizeclasstable.h @@ -112,7 +112,9 @@ namespace snmalloc { if ((size-1) <= (SLAB_SIZE-1)) { - return sizeclass_metadata.sizeclass_lookup[sizeclass_lookup_index(size)]; + auto index = sizeclass_lookup_index(size); + ASSUME(index <= sizeclass_lookup_index(SLAB_SIZE)); + return sizeclass_metadata.sizeclass_lookup[index]; } // Don't use sizeclasses that are not a multiple of the alignment. diff --git a/src/mem/slab.h b/src/mem/slab.h index 3b70680..850b595 100644 --- a/src/mem/slab.h +++ b/src/mem/slab.h @@ -48,7 +48,8 @@ namespace snmalloc assert(sl.get_head() == (SlabLink*)((size_t)this + meta.link)); assert(!meta.is_full()); - void* p; + void* p = nullptr; + bool p_has_value = false; if (head == 1) { @@ -62,7 +63,7 @@ namespace snmalloc p = pointer_offset(this, meta.link); meta.set_full(); sl.pop(); - goto finish1; + p_has_value = true; } else { @@ -104,6 +105,7 @@ namespace snmalloc } } + if (!p_has_value) { p = pointer_offset(this, meta.head); @@ -119,7 +121,6 @@ namespace snmalloc assert (is_start_of_object(Superslab::get(p), p)); - finish1: meta.debug_slab_invariant(is_short(), this); if constexpr (zero_mem == YesZero)