generic: use qrand() instead of rand()

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-03-19 13:31:07 +02:00
parent 54c94b7614
commit 90f6404e20
7 changed files with 6 additions and 11 deletions

View file

@ -299,9 +299,8 @@ main(void)
initConfig();
/* for QSettings */
srand(time(0));
for (i = 0; i < 10000; i++) {
sprintf(qtrc, "/tmp/%010d", rand());
sprintf(qtrc, "/tmp/%010d", qrand());
if (!mkdir(qtrc, 0700))
goto okay;
}

View file

@ -24,7 +24,7 @@
#include <qgl.h>
#define FLICKER_FRAMES_DELAY 8
#define DRAND ((float)rand() / (float)RAND_MAX) /*random float between 0 and 1*/
#define DRAND ((float)qrand() / (float)RAND_MAX) /*random float between 0 and 1*/
/* -- Particle class.
* Sets initial parameters and takes care of updating physics for a single

View file

@ -232,7 +232,7 @@ void kVmSaver::readSettings()
int kVmSaver::getRandom( const int max_value ) {
return (int)( vm_random(&(pool_state->pool->vm_random_data))*1.0*(max_value + 1.0)/
(VM_RAND_MAX + 1.0) );
// return (int)( rand()*1.0*(max_value + 1.0)/
// return (int)( qrand()*1.0*(max_value + 1.0)/
// (RAND_MAX + 1.0) );
}
void kVmSaver::modifyArea( const int op ) {

View file

@ -661,7 +661,7 @@ void KPendulumSaver::doTimeStep()
(eyePhi1<angleLimit)
|| ((eyePhi1<M_PI+angleLimit) && (eyePhi1>M_PI-angleLimit))
|| (eyePhi1>2*M_PI-angleLimit);
eyePhi1 = double(rand())/RAND_MAX * 2*M_PI)
eyePhi1 = double(qrand())/RAND_MAX * 2*M_PI)
{
}
// new delta phi for next change

View file

@ -105,8 +105,6 @@ KPartSaver::KPartSaver( WId id )
if( !g_inited ) {
g_inited = true;
srand( time(0) );
// install signal handler
signal( SIGINT, exitHandler ); // Ctrl-C will cause a clean exit...
signal( SIGTERM, exitHandler ); // "kill"...
@ -231,7 +229,7 @@ void KPartSaver::next( bool random )
while( m_media.count()>0 ) {
if( random )
m_current = rand() % m_media.count();
m_current = qrand() % m_media.count();
else
m_current++;

View file

@ -112,7 +112,6 @@ KWalletD::KWalletD()
_useGpg = true;
#endif
srand(time(0));
_showingFailureNotify = false;
_closeIdle = false;
_idleTime = 0;
@ -169,7 +168,7 @@ int KWalletD::generateHandle() {
// ASSUMPTION: RAND_MAX is fairly large.
do {
rc = rand();
rc = qrand();
} while (_wallets.contains(rc) || rc == 0);
return rc;

View file

@ -818,7 +818,6 @@ QString Quicklaunch::determineNewDesktopFilePath(const QString &baseName)
while(QFile::exists(desktopFilePath)) {
if (appendix.isEmpty()) {
qsrand(QDateTime::currentDateTime().toTime_t());
appendix += '-';
}