From efe215809b28f88dd89a9c9e90a66c1366fcb281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 10 May 2024 01:51:22 +0200 Subject: [PATCH] glib/glib-private: Mark the dynamic LSAN checks as unlikely It's not normal to run programs with leak sanitizer enabled, so let's mark those checks as such, in case the compiler can optimize them --- glib/glib-private.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/glib/glib-private.h b/glib/glib-private.h index 3417dfaf6..4dd0c2020 100644 --- a/glib/glib-private.h +++ b/glib/glib-private.h @@ -100,7 +100,7 @@ g_leak_sanitizer_is_supported (void) #if defined (_GLIB_ADDRESS_SANITIZER) return TRUE; #elif defined (HAS_DYNAMIC_ASAN_LOADING) - return __lsan_enable != NULL && __lsan_ignore_object != NULL; + return G_UNLIKELY (__lsan_enable != NULL && __lsan_ignore_object != NULL); #else return FALSE; #endif @@ -122,7 +122,7 @@ g_ignore_leak (gconstpointer p) if (p != NULL) __lsan_ignore_object (p); #elif defined (HAS_DYNAMIC_ASAN_LOADING) - if (p != NULL && __lsan_ignore_object != NULL) + if (G_LIKELY (p != NULL) && G_UNLIKELY (__lsan_ignore_object != NULL)) __lsan_ignore_object (p); #endif } @@ -166,7 +166,7 @@ g_begin_ignore_leaks (void) #if defined (_GLIB_ADDRESS_SANITIZER) __lsan_disable (); #elif defined (HAS_DYNAMIC_ASAN_LOADING) - if (__lsan_disable != NULL) + if (G_UNLIKELY (__lsan_disable != NULL)) __lsan_disable (); #endif } @@ -183,7 +183,7 @@ g_end_ignore_leaks (void) #if defined (_GLIB_ADDRESS_SANITIZER) __lsan_enable (); #elif defined (HAS_DYNAMIC_ASAN_LOADING) - if (__lsan_enable != NULL) + if (G_UNLIKELY (__lsan_enable != NULL)) __lsan_enable (); #endif }