From 06149aa156507b9a09a74b5f8bf7744522c4ceb2 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 16 Nov 2018 15:12:10 -0500 Subject: [PATCH] enable readability-else-after-return tidy check --- Makefile | 2 +- malloc.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index cca5b9c..9676452 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ endif CFLAGS := -std=c11 $(SHARED_FLAGS) -Wmissing-prototypes CXXFLAGS := -std=c++14 $(SHARED_FLAGS) LDFLAGS := -Wl,--as-needed,-z,defs,-z,relro,-z,now,-z,nodlopen,-z,text -TIDY_CHECKS := -checks=bugprone-*,-bugprone-macro-parentheses,cert-*,clang-analyzer-*,readability-*,-readability-else-after-return,-readability-inconsistent-declaration-parameter-name,-readability-named-parameter +TIDY_CHECKS := -checks=bugprone-*,-bugprone-macro-parentheses,cert-*,clang-analyzer-*,readability-*,-readability-inconsistent-declaration-parameter-name,-readability-named-parameter SOURCES := chacha.c malloc.c memory.c pages.c random.c util.c OBJECTS := $(SOURCES:.c=.o) diff --git a/malloc.c b/malloc.c index a118b9f..c4c4e4e 100644 --- a/malloc.c +++ b/malloc.c @@ -344,10 +344,12 @@ static bool has_free_slots(size_t slots, struct slab_metadata *metadata) { if (slots <= 64) { u64 masked = metadata->bitmap[0] | get_mask(slots); return masked != ~0UL; - } else if (slots <= 128) { + } + if (slots <= 128) { u64 masked = metadata->bitmap[1] | get_mask(slots - 64); return metadata->bitmap[0] != ~0UL || masked != ~0UL; - } else if (slots <= 192) { + } + if (slots <= 192) { u64 masked = metadata->bitmap[2] | get_mask(slots - 128); return metadata->bitmap[0] != ~0UL || metadata->bitmap[1] != ~0UL || masked != ~0UL; } @@ -434,7 +436,9 @@ static inline void *allocate_small(size_t requested_size) { mutex_unlock(&c->lock); return p; - } else if (c->free_slabs_head != NULL) { + } + + if (c->free_slabs_head != NULL) { struct slab_metadata *metadata = c->free_slabs_head; metadata->canary_value = get_random_canary(&c->rng);