Skip to content

Commit 57315a6

Browse files
Merge #1813: Remove trailing spaces and introduce -Wtrailing-whitespace=any compiler flag
86cae58 build: Add `-Wleading-whitespace=spaces` compiler flag (Hennadii Stepanov) fb229e7 build: Add `-Wtrailing-whitespace=any` compiler flag (Hennadii Stepanov) 13e3bee 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 bitcoin/bitcoin#34412. ACKs for top commit: real-or-random: utACK 86cae58 Tree-SHA512: 87911af96321eb3fc185f4d5c30ca3546bfd952c5722e1eeac9dd8c278a4bc08d99a85b79342ca705598a7a64b940427402d32e46f5c078061ad7fdf2482334c
2 parents 453949a + 86cae58 commit 57315a6

File tree

6 files changed

+12
-3
lines changed

6 files changed

+12
-3
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,15 @@ else()
217217
try_append_c_flags(-Wcast-align=strict) # GCC >= 8.0.
218218
try_append_c_flags(-Wconditional-uninitialized) # Clang >= 3.0 only.
219219
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.
220+
try_append_c_flags(-Wleading-whitespace=spaces) # GCC >= 15.0
220221
try_append_c_flags(-Wnested-externs)
221222
try_append_c_flags(-Wno-long-long) # GCC >= 3.0, -Wlong-long is implied by -pedantic.
222223
try_append_c_flags(-Wno-overlength-strings) # GCC >= 4.2, -Woverlength-strings is implied by -pedantic.
223224
try_append_c_flags(-Wno-unused-function) # GCC >= 3.0, -Wunused-function is implied by -Wall.
224225
try_append_c_flags(-Wreserved-identifier) # Clang >= 13.0 only.
225226
try_append_c_flags(-Wshadow)
226227
try_append_c_flags(-Wstrict-prototypes)
228+
try_append_c_flags(-Wtrailing-whitespace=any) # GCC >= 15.0
227229
try_append_c_flags(-Wundef)
228230
endif()
229231

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ AC_DEFUN([SECP_TRY_APPEND_DEFAULT_CFLAGS], [
111111
SECP_TRY_APPEND_CFLAGS([-Wcast-align=strict], $1) # GCC >= 8.0
112112
SECP_TRY_APPEND_CFLAGS([-Wconditional-uninitialized], $1) # Clang >= 3.0 only
113113
SECP_TRY_APPEND_CFLAGS([-Wreserved-identifier], $1) # Clang >= 13.0 only
114+
SECP_TRY_APPEND_CFLAGS([-Wtrailing-whitespace=any], $1) # GCC >= 15.0
115+
SECP_TRY_APPEND_CFLAGS([-Wleading-whitespace=spaces], $1) # GCC >= 15.0
114116
115117
CFLAGS="$SECP_TRY_APPEND_DEFAULT_CFLAGS_saved_CFLAGS"
116118
fi

include/secp256k1.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ SECP256K1_API void secp256k1_context_destroy(
349349
* writes the message to stderr and calls abort. This default callback can be
350350
* replaced at link time if the preprocessor macro
351351
* USE_EXTERNAL_DEFAULT_CALLBACKS is defined, which is the case if the build
352-
* has been configured with --enable-external-default-callbacks (GNU Autotools) or
352+
* has been configured with --enable-external-default-callbacks (GNU Autotools) or
353353
* -DSECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS=ON (CMake). Then the
354354
* following two symbols must be provided to link against:
355355
* - void secp256k1_default_illegal_callback_fn(const char *message, void *data);

src/bench.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static void print_number(const int64_t x) {
5959
y /= 10;
6060
}
6161
} else if (c == 0) { /* fractional part is 0 */
62-
buffer[--ptr] = '0';
62+
buffer[--ptr] = '0';
6363
}
6464
buffer[--ptr] = '.';
6565
do {

src/checkmem.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,15 @@
7878
# if defined(__clang__) && defined(__APPLE__)
7979
# pragma clang diagnostic push
8080
# pragma clang diagnostic ignored "-Wreserved-identifier"
81+
# elif defined(__GNUC__) && (__GNUC__ >= 15)
82+
# pragma GCC diagnostic push
83+
# pragma GCC diagnostic ignored "-Wtrailing-whitespace"
8184
# endif
8285
# include <valgrind/memcheck.h>
8386
# if defined(__clang__) && defined(__APPLE__)
8487
# pragma clang diagnostic pop
88+
# elif defined(__GNUC__) && (__GNUC__ >= 15)
89+
# pragma GCC diagnostic pop
8590
# endif
8691
# define SECP256K1_CHECKMEM_ENABLED 1
8792
# define SECP256K1_CHECKMEM_UNDEFINE(p, len) VALGRIND_MAKE_MEM_UNDEFINED((p), (len))

src/field.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ static void secp256k1_fe_add_int(secp256k1_fe *r, int a);
233233
#define secp256k1_fe_mul_int(r, a) ASSERT_INT_CONST_AND_DO(a, secp256k1_fe_mul_int_unchecked(r, a))
234234

235235
/** Like secp256k1_fe_mul_int but a is not checked to be an integer constant expression.
236-
*
236+
*
237237
* Should not be called directly outside of tests.
238238
*/
239239
static void secp256k1_fe_mul_int_unchecked(secp256k1_fe *r, int a);

0 commit comments

Comments
 (0)