diff mbox series

[v3,2/4] malloc: Don't use ifdefs for SYS_MALLOC_DEFAULT_TO_INIT

Message ID 20230928144458.2511087-3-sean.anderson@seco.com
State Changes Requested
Delegated to: Tom Rini
Headers show
Series [v3,1/4] common: Only mark malloc initialized after mem_malloc_init | expand

Commit Message

Sean Anderson Sept. 28, 2023, 2:44 p.m. UTC
With CONFIG_IS_ENABLED we can eliminate some ifdefs.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/dlmalloc.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index c2f5a7347b8..c7cd7815a27 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -575,9 +575,7 @@  static mbinptr av_[NAV * 2 + 2] = {
  IAV(120), IAV(121), IAV(122), IAV(123), IAV(124), IAV(125), IAV(126), IAV(127)
 };
 
-#ifdef CONFIG_SYS_MALLOC_DEFAULT_TO_INIT
 static void malloc_init(void);
-#endif
 
 ulong mem_malloc_start = 0;
 ulong mem_malloc_end = 0;
@@ -612,9 +610,8 @@  void mem_malloc_init(ulong start, ulong size)
 	mem_malloc_end = start + size;
 	mem_malloc_brk = start;
 
-#ifdef CONFIG_SYS_MALLOC_DEFAULT_TO_INIT
-	malloc_init();
-#endif
+	if (CONFIG_IS_ENABLED(SYS_MALLOC_DEFAULT_TO_INIT))
+		malloc_init();
 
 	debug("using memory %#lx-%#lx for malloc()\n", mem_malloc_start,
 	      mem_malloc_end);
@@ -719,7 +716,6 @@  static unsigned int max_n_mmaps = 0;
 static unsigned long max_mmapped_mem = 0;
 #endif
 
-#ifdef CONFIG_SYS_MALLOC_DEFAULT_TO_INIT
 static void malloc_init(void)
 {
 	int i, j;
@@ -748,7 +744,6 @@  static void malloc_init(void)
 	memset((void *)&current_mallinfo, 0, sizeof(struct mallinfo));
 #endif
 }
-#endif
 
 /*
   Debugging support