malloc: Enable assertions if UNIT_TEST is enabled
PATCH 1/1 malloc: Enable assertions if UNIT_TEST is enabled
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.
---
common/dlmalloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
common/dlmalloc.c +4 -4
@@ -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>
Signature · 1 line
2.37.1
Quoted 2 lines · Sean Anderson
dlmalloc has some sanity checks it performs on
free()which can help
detect
Quoted 1 line
memory corruption. However, they are only enabled if DEBUG is defined
before
Quoted 9 lines
including
common.h. Define DEBUG earlier ifUNIT_TESTis enabled so that assertions are enabled in sandbox.Signed-off-by Sean Anderson <[email protected]>---
common/dlmalloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Quoted 7 lines · Sean Anderson
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 includingcommon.h. Define DEBUG earlier ifUNIT_TESTis enabled so that assertions are enabled in sandbox.Signed-off-by Sean Anderson <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom