Skip to content

Commit b0d8c60

Browse files
committed
[secp256k1] initialize variable in tests
Summary: > This was detected while running the tests with the `-Wconditional-uninitialized` flag > > ``` > ./autogen.sh > CC=clang CFLAGS="-Wconditional-uninitialized" ./configure > make check > ``` > > The resulting warning is a false positive, but setting the value to -1 > ensures that the CHECK below will fail if recid is never written to. This is a backport of [[bitcoin-core/secp256k1#889 | secp256k1#889]] It should allow us to finally land D9110 Test Plan: To check that this diff does not break existing tests: `ninja && ninja check-secp256k1` To check that this removes the compilation warning: rebased D9110 on top of this Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D9372
1 parent da7fa24 commit b0d8c60

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/secp256k1/src/tests.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -4372,8 +4372,10 @@ void test_ecdsa_sign_verify(void) {
43724372
secp256k1_scalar one;
43734373
secp256k1_scalar msg, key;
43744374
secp256k1_scalar sigr, sigs;
4375-
int recid;
43764375
int getrec;
4376+
/* Initialize recid to suppress a false positive -Wconditional-uninitialized in clang.
4377+
VG_UNDEF ensures that valgrind will still treat the variable as uninitialized. */
4378+
int recid = -1; VG_UNDEF(&recid, sizeof(recid));
43774379
random_scalar_order_test(&msg);
43784380
random_scalar_order_test(&key);
43794381
secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &pubj, &key);

0 commit comments

Comments
 (0)