build: Add `-Wtrailing-whitespace=any` compiler flag
What changed, and why it matters
This commit only adds a new compiler warning flag that flags trailing whitespace in source code. It is a code-quality/build-hygiene change, not a security fix. The only functional code change is a pragma to suppress that warning around a system header (Valgrind's memcheck.h) that may contain trailing whitespace. There is no vulnerability being patched.
No security action needed. Treat as normal build-system hygiene commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change adds -Wtrailing-whitespace=any to the default warning set for GCC 15+ in both CMake and autotools builds. Because the Valgrind memcheck.h system header can trigger this warning, a GCC diagnostic push/pop with -Wtrailing-whitespace ignored is added in src/checkmem.h around the #include <valgrind/memcheck.h>. No cryptographic, memory-safety, or consensus-relevant code is modified.
Changed components
build system (CMakeLists.txt, configure.ac)src/checkmem.h diagnostic pragmasInspect captured patch +7 / −0
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 01b14b5..4953a4b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -224,6 +224,7 @@ else()
try_append_c_flags(-Wreserved-identifier) # Clang >= 13.0 only.
try_append_c_flags(-Wshadow)
try_append_c_flags(-Wstrict-prototypes)
+ try_append_c_flags(-Wtrailing-whitespace=any) # GCC >= 15.0
try_append_c_flags(-Wundef)
endif()
diff --git a/configure.ac b/configure.ac
index 6efb4aa..e68af3c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -111,6 +111,7 @@ AC_DEFUN([SECP_TRY_APPEND_DEFAULT_CFLAGS], [
SECP_TRY_APPEND_CFLAGS([-Wcast-align=strict], $1) # GCC >= 8.0
SECP_TRY_APPEND_CFLAGS([-Wconditional-uninitialized], $1) # Clang >= 3.0 only
SECP_TRY_APPEND_CFLAGS([-Wreserved-identifier], $1) # Clang >= 13.0 only
+ SECP_TRY_APPEND_CFLAGS([-Wtrailing-whitespace=any], $1) # GCC >= 15.0
CFLAGS="$SECP_TRY_APPEND_DEFAULT_CFLAGS_saved_CFLAGS"
fi
diff --git a/src/checkmem.h b/src/checkmem.h
index 08eae47..88c65c8 100644
--- a/src/checkmem.h
+++ b/src/checkmem.h
@@ -78,10 +78,15 @@
# if defined(__clang__) && defined(__APPLE__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wreserved-identifier"
+# elif defined(__GNUC__) && (__GNUC__ >= 15)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wtrailing-whitespace"
# endif
# include <valgrind/memcheck.h>
# if defined(__clang__) && defined(__APPLE__)
# pragma clang diagnostic pop
+# elif defined(__GNUC__) && (__GNUC__ >= 15)
+# pragma GCC diagnostic pop
# endif
# define SECP256K1_CHECKMEM_ENABLED 1
# define SECP256K1_CHECKMEM_UNDEFINE(p, len) VALGRIND_MAKE_MEM_UNDEFINED((p), (len))
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.