From 13e3bee5048fe9115e607f1065af3c82a22192ac Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 28 Jan 2026 11:10:47 +0000 Subject: [PATCH 1/3] refactor: Remove trailing whitespace --- include/secp256k1.h | 2 +- src/bench.h | 2 +- src/field.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/secp256k1.h b/include/secp256k1.h index 2799d4a1f8..9de45f1f7d 100644 --- a/include/secp256k1.h +++ b/include/secp256k1.h @@ -349,7 +349,7 @@ SECP256K1_API void secp256k1_context_destroy( * writes the message to stderr and calls abort. This default callback can be * replaced at link time if the preprocessor macro * USE_EXTERNAL_DEFAULT_CALLBACKS is defined, which is the case if the build - * has been configured with --enable-external-default-callbacks (GNU Autotools) or + * has been configured with --enable-external-default-callbacks (GNU Autotools) or * -DSECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS=ON (CMake). Then the * following two symbols must be provided to link against: * - void secp256k1_default_illegal_callback_fn(const char *message, void *data); diff --git a/src/bench.h b/src/bench.h index 72a3f211b6..f88277aa3f 100644 --- a/src/bench.h +++ b/src/bench.h @@ -59,7 +59,7 @@ static void print_number(const int64_t x) { y /= 10; } } else if (c == 0) { /* fractional part is 0 */ - buffer[--ptr] = '0'; + buffer[--ptr] = '0'; } buffer[--ptr] = '.'; do { diff --git a/src/field.h b/src/field.h index e3f0234f5f..945029ecd8 100644 --- a/src/field.h +++ b/src/field.h @@ -233,7 +233,7 @@ static void secp256k1_fe_add_int(secp256k1_fe *r, int a); #define secp256k1_fe_mul_int(r, a) ASSERT_INT_CONST_AND_DO(a, secp256k1_fe_mul_int_unchecked(r, a)) /** Like secp256k1_fe_mul_int but a is not checked to be an integer constant expression. - * + * * Should not be called directly outside of tests. */ static void secp256k1_fe_mul_int_unchecked(secp256k1_fe *r, int a); From fb229e7602e47de1df23141838c0596a4b64aeca Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 29 Jan 2026 12:40:41 +0000 Subject: [PATCH 2/3] build: Add `-Wtrailing-whitespace=any` compiler flag --- CMakeLists.txt | 1 + configure.ac | 1 + src/checkmem.h | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 01b14b5375..4953a4b417 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 6efb4aab13..e68af3cabe 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 08eae47d78..88c65c8ebf 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 # 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)) From 86cae58d2f342f8a3b49dd70dca8989cb271c504 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 29 Jan 2026 12:43:40 +0000 Subject: [PATCH 3/3] build: Add `-Wleading-whitespace=spaces` compiler flag --- CMakeLists.txt | 1 + configure.ac | 1 + 2 files changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4953a4b417..4ef69c0891 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,6 +217,7 @@ else() try_append_c_flags(-Wcast-align=strict) # GCC >= 8.0. try_append_c_flags(-Wconditional-uninitialized) # Clang >= 3.0 only. try_append_c_flags(-Wextra) # GCC >= 3.4, this is the newer name of -W, which we don't use because older GCCs will warn about unused functions. + try_append_c_flags(-Wleading-whitespace=spaces) # GCC >= 15.0 try_append_c_flags(-Wnested-externs) try_append_c_flags(-Wno-long-long) # GCC >= 3.0, -Wlong-long is implied by -pedantic. try_append_c_flags(-Wno-overlength-strings) # GCC >= 4.2, -Woverlength-strings is implied by -pedantic. diff --git a/configure.ac b/configure.ac index e68af3cabe..a21447ced5 100644 --- a/configure.ac +++ b/configure.ac @@ -112,6 +112,7 @@ AC_DEFUN([SECP_TRY_APPEND_DEFAULT_CFLAGS], [ 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 + SECP_TRY_APPEND_CFLAGS([-Wleading-whitespace=spaces], $1) # GCC >= 15.0 CFLAGS="$SECP_TRY_APPEND_DEFAULT_CFLAGS_saved_CFLAGS" fi