@@ -5262,17 +5262,19 @@ void test_ecdsa_sign_verify(void) {
52625262    secp256k1_scalar  msg , key ;
52635263    secp256k1_scalar  sigr , sigs ;
52645264    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 ;
52685266    random_scalar_order_test (& msg );
52695267    random_scalar_order_test (& key );
52705268    secp256k1_ecmult_gen (& ctx -> ecmult_gen_ctx , & pubj , & key );
52715269    secp256k1_ge_set_gej (& pub , & pubj );
52725270    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. */ 
52745273    if  (getrec ) {
5274+         random_sign (& sigr , & sigs , & key , & msg , & recid );
52755275        CHECK (recid  >= 0  &&  recid  <  4 );
5276+     } else  {
5277+         random_sign (& sigr , & sigs , & key , & msg , NULL );
52765278    }
52775279    CHECK (secp256k1_ecdsa_sig_verify (& ctx -> ecmult_ctx , & sigr , & sigs , & pub , & msg ));
52785280    secp256k1_scalar_set_int (& one , 1 );
0 commit comments