Merge bitcoin-core/secp256k1#1813: Remove trailing spaces and introduce -Wtrailing-whitespace=any compiler flag

86cae58d2f build: Add `-Wleading-whitespace=spaces` compiler flag (Hennadii Stepanov)
fb229e7602 build: Add `-Wtrailing-whitespace=any` compiler flag (Hennadii Stepanov)
13e3bee504 refactor: Remove trailing whitespace (Hennadii Stepanov)

Pull request description:

  This PR removes trailing whitespace and introduces the `-Wtrailing-whitespace=any` compiler flag. This enforces the rule from [CONTRIBUTING.md](https://github.com/bitcoin-core/secp256k1/blob/master/CONTRIBUTING.md#style-conventions) ("Avoid trailing whitespace") directly in the CI.

  This fix is required to unbreak Bitcoin Core CI builds [using GCC 15](https://github.com/hebasto/bitcoin-core-nightly/actions/runs/21436418669) after merging https://github.com/bitcoin/bitcoin/pull/34412.

ACKs for top commit:
  real-or-random:
    utACK 86cae58d2f

Tree-SHA512: 87911af96321eb3fc185f4d5c30ca3546bfd952c5722e1eeac9dd8c278a4bc08d99a85b79342ca705598a7a64b940427402d32e46f5c078061ad7fdf2482334c
This commit is contained in:
merge-script
2026-02-02 16:19:59 +01:00
6 changed files with 12 additions and 3 deletions

View File

@@ -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.
@@ -224,6 +225,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()

View File

@@ -111,6 +111,8 @@ 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
SECP_TRY_APPEND_CFLAGS([-Wleading-whitespace=spaces], $1) # GCC >= 15.0
CFLAGS="$SECP_TRY_APPEND_DEFAULT_CFLAGS_saved_CFLAGS"
fi

View File

@@ -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);

View File

@@ -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 {

View File

@@ -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))

View File

@@ -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);