@@ -126,7 +126,7 @@ uint64_t GetRdRand() noexcept
126
126
{
127
127
// RdRand may very rarely fail. Invoke it up to 10 times in a loop to reduce this risk.
128
128
#ifdef __i386__
129
- uint8_t ok;
129
+ uint8_t ok = 0 ;
130
130
// Initialize to 0 to silence a compiler warning that r1 or r2 may be used
131
131
// uninitialized. Even if rdrand fails (!ok) it will set the output to 0,
132
132
// but there is no way that the compiler could know that.
@@ -141,7 +141,7 @@ uint64_t GetRdRand() noexcept
141
141
}
142
142
return (((uint64_t )r2) << 32 ) | r1;
143
143
#elif defined(__x86_64__) || defined(__amd64__)
144
- uint8_t ok;
144
+ uint8_t ok = 0 ;
145
145
uint64_t r1 = 0 ; // See above why we initialize to 0.
146
146
for (int i = 0 ; i < 10 ; ++i) {
147
147
__asm__ volatile (" .byte 0x48, 0x0f, 0xc7, 0xf0; setc %1" : " =a" (r1), " =q" (ok) :: " cc" ); // rdrand %rax
@@ -162,7 +162,7 @@ uint64_t GetRdSeed() noexcept
162
162
// RdSeed may fail when the HW RNG is overloaded. Loop indefinitely until enough entropy is gathered,
163
163
// but pause after every failure.
164
164
#ifdef __i386__
165
- uint8_t ok;
165
+ uint8_t ok = 0 ;
166
166
uint32_t r1, r2;
167
167
do {
168
168
__asm__ volatile (" .byte 0x0f, 0xc7, 0xf8; setc %1" : " =a" (r1), " =q" (ok) :: " cc" ); // rdseed %eax
@@ -215,7 +215,7 @@ void ReportHardwareRand()
215
215
*/
216
216
uint64_t GetRNDR () noexcept
217
217
{
218
- uint8_t ok;
218
+ uint8_t ok = 0 ;
219
219
uint64_t r1;
220
220
do {
221
221
// https://developer.arm.com/documentation/ddi0601/2022-12/AArch64-Registers/RNDR--Random-Number
@@ -233,7 +233,7 @@ uint64_t GetRNDR() noexcept
233
233
*/
234
234
uint64_t GetRNDRRS () noexcept
235
235
{
236
- uint8_t ok;
236
+ uint8_t ok = 0 ;
237
237
uint64_t r1;
238
238
do {
239
239
// https://developer.arm.com/documentation/ddi0601/2022-12/AArch64-Registers/RNDRRS--Reseeded-Random-Number
0 commit comments