From 50b35193ec6f8f342364742a69a607e967b39b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 21 Feb 2023 19:59:57 +0100 Subject: meson: merge our two valgrind configuration conditions into one Most of the support for valgrind was under HAVE_VALGRIND_VALGRIND_H, i.e. we would enable if the valgrind headers were found. The operations then we be conditionalized on RUNNING_UNDER_VALGRIND. But in a few places we had code which was conditionalized on VALGRIND, i.e. the config option. I noticed because I compiled with -Dvalgrind=true on a machine that didn't have valgrind.h, and the build failed because RUNNING_UNDER_VALGRIND was not defined. My first idea was to add a check that the header is present if the option is set, but it seems better to just remove the option. The code to support valgrind is trivial, and if we're !RUNNING_UNDER_VALGRIND, it has negligible cost. And the case of running under valgrind is always some special testing/debugging mode, so we should just do those extra steps to make valgrind output cleaner. Removing the option makes things simpler and we don't have to think if something should be covered by the one or the other configuration bit. I had a vague recollection that in some places we used -Dvalgrind=true not for valgrind support, but to enable additional cleanup under other sanitizers. But that code would fail to build without the valgrind headers anyway, so I'm not sure if that was still used. If there are uses like that, we can extend the condition for cleanup_pools(). --- src/libsystemd-network/test-dhcp-client.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/libsystemd-network') diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c index 863649f6df..e4354199e1 100644 --- a/src/libsystemd-network/test-dhcp-client.c +++ b/src/libsystemd-network/test-dhcp-client.c @@ -9,6 +9,9 @@ #include #include #include +#if HAVE_VALGRIND_VALGRIND_H +# include +#endif #include "sd-dhcp-client.h" #include "sd-event.h" @@ -546,11 +549,12 @@ int main(int argc, char *argv[]) { test_discover_message(e); test_addr_acq(e); -#if VALGRIND +#if HAVE_VALGRIND_VALGRIND_H /* Make sure the async_close thread has finished. * valgrind would report some of the phread_* structures * as not cleaned up properly. */ - sleep(1); + if (RUNNING_ON_VALGRIND) + sleep(1); #endif return 0; -- cgit v1.2.1