From 00d5982da2f5f2595b634b957c7d0b990e12b37b Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 17 Apr 2023 09:25:48 +0200 Subject: [PATCH] lib:talloc: Don't optimize the speed test If the speed test gets optimized, the malloc() and free() might be replaced by stack allocations. Signed-off-by: Andreas Schneider Reviewed-by: Martin Schwenke --- lib/talloc/testsuite.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/talloc/testsuite.c b/lib/talloc/testsuite.c index b67897efddf..a4a3f4e89d1 100644 --- a/lib/talloc/testsuite.c +++ b/lib/talloc/testsuite.c @@ -42,6 +42,14 @@ #include "talloc_testsuite.h" +#ifndef disable_optimization +#if __has_attribute(optimize) +#define disable_optimization __attribute__((optimize("O0"))) +#else /* disable_optimization */ +#define disable_optimization +#endif +#endif /* disable_optimization */ + static struct timeval private_timeval_current(void) { struct timeval tv; @@ -854,6 +862,7 @@ static bool test_unref_reparent(void) /* measure the speed of talloc versus malloc */ +static bool test_speed(void) disable_optimization; static bool test_speed(void) { void *ctx = talloc_new(NULL); -- 2.47.3