Skip to content

Commit 3d2cf6c

Browse files
committed
initialize variable in tests
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.
1 parent 24d1656 commit 3d2cf6c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/tests.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4324,8 +4324,10 @@ void test_ecdsa_sign_verify(void) {
43244324
secp256k1_scalar one;
43254325
secp256k1_scalar msg, key;
43264326
secp256k1_scalar sigr, sigs;
4327-
int recid;
43284327
int getrec;
4328+
/* Initialize recid to suppress a false positive -Wconditional-uninitialized in clang.
4329+
VG_UNDEF ensures that valgrind will still treat the variable as uninitialized. */
4330+
int recid = -1; VG_UNDEF(&recid, sizeof(recid));
43294331
random_scalar_order_test(&msg);
43304332
random_scalar_order_test(&key);
43314333
secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &pubj, &key);

0 commit comments

Comments
 (0)