]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
build: Check sanitize argument value
authorSven Püschel <s.pueschel@pengutronix.de>
Tue, 28 Oct 2025 11:11:36 +0000 (12:11 +0100)
committerGuillem Jover <guillem@hadrons.org>
Mon, 18 May 2026 02:56:59 +0000 (04:56 +0200)
Check the value of the sanitize argument to determine if sanitize should
be enabled. This fixes that sanitize is enabled when --disable-sanitize
is passed to the configure script.

The third AC_ARG_ENABLE parameter defines an action, if the parameter is
present, but doesn't check its value. Therefore it is also invoked if the
parameter is disabled or --enable-foo=no is set. Therefore don't define
these actions and instead check the value with an AS_IF statement
afterwards, as shown in [1].

  [1] https://autotools.info/autoconf/arguments.html

[guillem@hadrons.org:
 - Minor coding style fixes.
 - Minor wording fixes in commit message. ]

Fixes: 257800a03c6b ("build: Add support for sanitizer compiler flags")
Closes: !31
Signed-off-by: Guillem Jover <guillem@hadrons.org>
configure.ac

index 1c1181ba675eb679f50229ad08eda4a150a687ea..463fb97a7147bc57353bf8be66e0c49e0136d09e 100644 (file)
@@ -437,8 +437,8 @@ AS_IF([test "$user_CFLAGS" = unset], [
   CFLAGS="$CFLAGS $LIBBSD_COMPILER_FLAGS"
 
   AC_ARG_ENABLE([sanitize],
-    [AS_HELP_STRING([--enable-sanitize], [enable compiler sanitizer support])],
-  [
+    [AS_HELP_STRING([--enable-sanitize], [enable compiler sanitizer support])])
+  AS_IF([test "x$enable_sanitize" = "xyes"], [
     LIBBSD_COMPILER_FLAGS=''
     LIBBSD_CHECK_COMPILER_FLAG([-fsanitize=address])
     LIBBSD_CHECK_COMPILER_FLAG([-fsanitize=leak])