[PATCH] malloc: Enable assertions if UNIT_TEST is enabled

Sean Anderson seanga2 at gmail.com
Sun Oct 8 04:01:56 CEST 2023


dlmalloc has some sanity checks it performs on free() which can help detect
memory corruption. However, they are only enabled if DEBUG is defined before
including common.h. Define DEBUG earlier if UNIT_TEST is enabled so that
assertions are enabled in sandbox.

Signed-off-by: Sean Anderson <seanga2 at gmail.com>
---

 common/dlmalloc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index dcecdb8623c..500a0dbda89 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -8,14 +8,14 @@
  * as file malloc-2.6.6.c.
  */
 
+#if CONFIG_IS_ENABLED(UNIT_TEST)
+#define DEBUG
+#endif
+
 #include <common.h>
 #include <log.h>
 #include <asm/global_data.h>
 
-#if CONFIG_IS_ENABLED(UNIT_TEST)
-#define DEBUG
-#endif
-
 #include <malloc.h>
 #include <asm/io.h>
 #include <valgrind/memcheck.h>
-- 
2.37.1



More information about the U-Boot mailing list