From 1aeea0f39143a658caf34c44ac59cb7fc6bb5749 Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Fri, 11 Nov 2016 22:46:55 -0800 Subject: [PATCH] Simplify extent_quantize(). 2cdf07aba971d1e21edc203e7d4073b6ce8e72b9 (Fix extent_quantize() to handle greater-than-huge-size extents.) solved a non-problem; the expression passed in to index2size() was never too large. However the expression could in principle underflow, so fix the actual (latent) bug and remove unnecessary complexity. --- src/extent.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/extent.c b/src/extent.c index 828f627c..b1b894dc 100644 --- a/src/extent.c +++ b/src/extent.c @@ -16,12 +16,9 @@ extent_quantize(size_t size) assert(size > 0); ind = size2index(size + 1); - if (ind == NSIZES) { - /* - * Allocation requests can't directly create extents that exceed - * HUGE_MAXCLASS, but extent merging can create them. - */ - return (HUGE_MAXCLASS); + if (ind == 0) { + /* Avoid underflow. */ + return (index2size(0)); } ret = index2size(ind - 1); assert(ret <= size);