[libc-commits] [libc] [libc] Fix for unused variable warning (PR #98086)
via libc-commits
libc-commits at lists.llvm.org
Mon Jul 8 15:15:14 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Caslyn Tonelli (Caslyn)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/98086.diff
1 Files Affected:
- (modified) libc/src/__support/block.h (+1-2)
``````````diff
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");
``````````
</details>
https://github.com/llvm/llvm-project/pull/98086
More information about the libc-commits
mailing list