[libcalamares] Simplify filling the entropy buffer

This commit is contained in:
Adriaan de Groot 2021-09-21 12:02:26 +02:00
parent a393ffe126
commit ada13c19fd

View File

@ -18,15 +18,17 @@
CalamaresUtils::EntropySource CalamaresUtils::EntropySource
CalamaresUtils::getEntropy( int size, QByteArray& b ) CalamaresUtils::getEntropy( int size, QByteArray& b )
{ {
constexpr const char filler = char( 0xcb );
b.fill( filler );
b.clear(); b.clear();
if ( size < 1 ) if ( size < 1 )
{ {
return EntropySource::None; return EntropySource::None;
} }
b.resize( size ); b.fill( filler, size );
char* buffer = b.data(); char* buffer = b.data();
std::fill( buffer, buffer + size, 0xcb );
qint64 readSize = 0; qint64 readSize = 0;
QFile urandom( "/dev/urandom" ); QFile urandom( "/dev/urandom" );