@@ -5262,17 +5262,19 @@ void test_ecdsa_sign_verify(void) {
5262
5262
secp256k1_scalar msg , key ;
5263
5263
secp256k1_scalar sigr , sigs ;
5264
5264
int getrec ;
5265
- /* Initialize recid to suppress a false positive -Wconditional-uninitialized in clang.
5266
- VG_UNDEF ensures that valgrind will still treat the variable as uninitialized. */
5267
- int recid = -1 ; VG_UNDEF (& recid , sizeof (recid ));
5265
+ int recid ;
5268
5266
random_scalar_order_test (& msg );
5269
5267
random_scalar_order_test (& key );
5270
5268
secp256k1_ecmult_gen (& ctx -> ecmult_gen_ctx , & pubj , & key );
5271
5269
secp256k1_ge_set_gej (& pub , & pubj );
5272
5270
getrec = secp256k1_testrand_bits (1 );
5273
- random_sign (& sigr , & sigs , & key , & msg , getrec ?& recid :NULL );
5271
+ /* The specific way in which this conditional is written sidesteps a potential bug in clang.
5272
+ See the commit messages of the commit that introduced this comment for details. */
5274
5273
if (getrec ) {
5274
+ random_sign (& sigr , & sigs , & key , & msg , & recid );
5275
5275
CHECK (recid >= 0 && recid < 4 );
5276
+ } else {
5277
+ random_sign (& sigr , & sigs , & key , & msg , NULL );
5276
5278
}
5277
5279
CHECK (secp256k1_ecdsa_sig_verify (& ctx -> ecmult_ctx , & sigr , & sigs , & pub , & msg ));
5278
5280
secp256k1_scalar_set_int (& one , 1 );
0 commit comments