[Concept,14/35] malloc: Fix unused internal_memalign warning with mcheck

Message ID 20251210000737.180797-15-sjg@u-boot.org
State New
Headers
Series malloc: Add heap debugging commands and mcheck caller tracking |

Commit Message

Simon Glass Dec. 10, 2025, 12:07 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

When CONFIG_MCHECK_HEAP_PROTECTION is enabled, dlmemalign_impl() calls
dlmalloc_impl() directly since the mcheck wrapper handles alignment.
This leaves internal_memalign() unused, causing a compiler warning.

Guard internal_memalign() with a preprocessor check so it's only
compiled when needed (mcheck disabled or MSPACES enabled).

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 common/dlmalloc.c | 2 ++
 1 file changed, 2 insertions(+)
  

Patch

diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index b46be1899f0..efeff18653f 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -5309,6 +5309,7 @@  static mchunkptr try_realloc_chunk(mstate m, mchunkptr p, size_t nb,
 }
 #endif /* !defined(__UBOOT__) || !NO_REALLOC_IN_PLACE */
 
+#if !CONFIG_IS_ENABLED(MCHECK_HEAP_PROTECTION) || MSPACES
 static void* internal_memalign(mstate m, size_t alignment, size_t bytes) {
   void* mem = 0;
   if (alignment <  MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */
@@ -5422,6 +5423,7 @@  static void* internal_memalign(mstate m, size_t alignment, size_t bytes) {
   }
   return mem;
 }
+#endif /* !CONFIG_MCHECK_HEAP_PROTECTION || MSPACES */
 
 /*
   Common support for independent_X routines, handling