[libc-commits] [libc] f6eda6f - [libc] Fix for unused variable warning (#98086)

via libc-commits libc-commits at lists.llvm.org
Mon Jul 8 16:56:31 PDT 2024


Author: Caslyn Tonelli
Date: 2024-07-08T16:56:28-07:00
New Revision: f6eda6fb7a335861d8a8ce32ea805830685f218d

URL: https://github.com/llvm/llvm-project/commit/f6eda6fb7a335861d8a8ce32ea805830685f218d
DIFF: https://github.com/llvm/llvm-project/commit/f6eda6fb7a335861d8a8ce32ea805830685f218d.diff

LOG: [libc] Fix for unused variable warning (#98086)

This fixes the `unused variable 'new_inner_size'` warning that arises
when `new_inner_size` is only used by `LIBC_ASSERT` by performing the
calculation directly in the macro.

Added: 
    

Modified: 
    libc/src/__support/block.h

Removed: 
    


################################################################################
diff  --git a/libc/src/__support/block.h b/libc/src/__support/block.h
index 026ea9063f416..e1b7aeaaf813c 100644
--- a/libc/src/__support/block.h
+++ b/libc/src/__support/block.h
@@ -442,8 +442,7 @@ Block<OffsetType, kAlign>::allocate(Block *block, size_t alignment,
 
   if (!info.block->is_usable_space_aligned(alignment)) {
     size_t adjustment = info.block->padding_for_alignment(alignment);
-    size_t new_inner_size = adjustment - BLOCK_OVERHEAD;
-    LIBC_ASSERT(new_inner_size % ALIGNMENT == 0 &&
+    LIBC_ASSERT((adjustment - BLOCK_OVERHEAD) % ALIGNMENT == 0 &&
                 "The adjustment calculation should always return a new size "
                 "that's a multiple of ALIGNMENT");
 


        


More information about the libc-commits mailing list