@@ -126,7 +126,7 @@ uint64_t GetRdRand() noexcept
126126{
127127 // RdRand may very rarely fail. Invoke it up to 10 times in a loop to reduce this risk.
128128#ifdef __i386__
129- uint8_t ok;
129+ uint8_t ok = 0 ;
130130 // Initialize to 0 to silence a compiler warning that r1 or r2 may be used
131131 // uninitialized. Even if rdrand fails (!ok) it will set the output to 0,
132132 // but there is no way that the compiler could know that.
@@ -141,7 +141,7 @@ uint64_t GetRdRand() noexcept
141141 }
142142 return (((uint64_t )r2) << 32 ) | r1;
143143#elif defined(__x86_64__) || defined(__amd64__)
144- uint8_t ok;
144+ uint8_t ok = 0 ;
145145 uint64_t r1 = 0 ; // See above why we initialize to 0.
146146 for (int i = 0 ; i < 10 ; ++i) {
147147 __asm__ volatile (" .byte 0x48, 0x0f, 0xc7, 0xf0; setc %1" : " =a" (r1), " =q" (ok) :: " cc" ); // rdrand %rax
@@ -162,7 +162,7 @@ uint64_t GetRdSeed() noexcept
162162 // RdSeed may fail when the HW RNG is overloaded. Loop indefinitely until enough entropy is gathered,
163163 // but pause after every failure.
164164#ifdef __i386__
165- uint8_t ok;
165+ uint8_t ok = 0 ;
166166 uint32_t r1, r2;
167167 do {
168168 __asm__ volatile (" .byte 0x0f, 0xc7, 0xf8; setc %1" : " =a" (r1), " =q" (ok) :: " cc" ); // rdseed %eax
@@ -215,7 +215,7 @@ void ReportHardwareRand()
215215 */
216216uint64_t GetRNDR () noexcept
217217{
218- uint8_t ok;
218+ uint8_t ok = 0 ;
219219 uint64_t r1;
220220 do {
221221 // https://developer.arm.com/documentation/ddi0601/2022-12/AArch64-Registers/RNDR--Random-Number
@@ -233,7 +233,7 @@ uint64_t GetRNDR() noexcept
233233 */
234234uint64_t GetRNDRRS () noexcept
235235{
236- uint8_t ok;
236+ uint8_t ok = 0 ;
237237 uint64_t r1;
238238 do {
239239 // https://developer.arm.com/documentation/ddi0601/2022-12/AArch64-Registers/RNDRRS--Reseeded-Random-Number
0 commit comments