From 4429a8c218d7bf7bc6de1de88bc31c834f771385 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 14 Mar 2023 20:03:42 +0000 Subject: [PATCH 1/2] Suppress `-Wunused-parameter` when building for coverage analysis --- CMakeLists.txt | 2 +- src/ecmult_impl.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddc6c7e..21bcb76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,7 +147,7 @@ else() endif() # Define custom "Coverage" build type. -set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O0 -DCOVERAGE=1 --coverage -Wno-unused-parameter" CACHE STRING +set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O0 -DCOVERAGE=1 --coverage" CACHE STRING "Flags used by the C compiler during \"Coverage\" builds." FORCE ) diff --git a/src/ecmult_impl.h b/src/ecmult_impl.h index 3776fe7..343963c 100644 --- a/src/ecmult_impl.h +++ b/src/ecmult_impl.h @@ -115,6 +115,7 @@ static void secp256k1_ecmult_odd_multiples_table(int n, secp256k1_ge *pre_a, sec } #define SECP256K1_ECMULT_TABLE_VERIFY(n,w) \ + (void)w; \ VERIFY_CHECK(((n) & 1) == 1); \ VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \ VERIFY_CHECK((n) <= ((1 << ((w)-1)) - 1)); From 5bb03c29116409ace8855e64bf2e2b2d45871469 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 21 Mar 2023 15:29:22 +0000 Subject: [PATCH 2/2] Replace `SECP256K1_ECMULT_TABLE_VERIFY` macro by a function --- src/ecmult_impl.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/ecmult_impl.h b/src/ecmult_impl.h index 343963c..bb337e6 100644 --- a/src/ecmult_impl.h +++ b/src/ecmult_impl.h @@ -114,14 +114,16 @@ static void secp256k1_ecmult_odd_multiples_table(int n, secp256k1_ge *pre_a, sec secp256k1_fe_mul(z, &ai.z, &d.z); } -#define SECP256K1_ECMULT_TABLE_VERIFY(n,w) \ - (void)w; \ - VERIFY_CHECK(((n) & 1) == 1); \ - VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \ +SECP256K1_INLINE static void secp256k1_ecmult_table_verify(int n, int w) { + (void)n; + (void)w; + VERIFY_CHECK(((n) & 1) == 1); + VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); VERIFY_CHECK((n) <= ((1 << ((w)-1)) - 1)); +} SECP256K1_INLINE static void secp256k1_ecmult_table_get_ge(secp256k1_ge *r, const secp256k1_ge *pre, int n, int w) { - SECP256K1_ECMULT_TABLE_VERIFY(n,w) + secp256k1_ecmult_table_verify(n,w); if (n > 0) { *r = pre[(n-1)/2]; } else { @@ -131,7 +133,7 @@ SECP256K1_INLINE static void secp256k1_ecmult_table_get_ge(secp256k1_ge *r, cons } SECP256K1_INLINE static void secp256k1_ecmult_table_get_ge_lambda(secp256k1_ge *r, const secp256k1_ge *pre, const secp256k1_fe *x, int n, int w) { - SECP256K1_ECMULT_TABLE_VERIFY(n,w) + secp256k1_ecmult_table_verify(n,w); if (n > 0) { secp256k1_ge_set_xy(r, &x[(n-1)/2], &pre[(n-1)/2].y); } else { @@ -141,7 +143,7 @@ SECP256K1_INLINE static void secp256k1_ecmult_table_get_ge_lambda(secp256k1_ge * } SECP256K1_INLINE static void secp256k1_ecmult_table_get_ge_storage(secp256k1_ge *r, const secp256k1_ge_storage *pre, int n, int w) { - SECP256K1_ECMULT_TABLE_VERIFY(n,w) + secp256k1_ecmult_table_verify(n,w); if (n > 0) { secp256k1_ge_from_storage(r, &pre[(n-1)/2]); } else {