Explicitly cast time value in cmSystemTools::RandomSeed
Use static_cast to avoid warnings like conversion to ‘unsigned int’ from ‘__time_t’ may alter its value conversion to ‘unsigned int’ from ‘__suseconds_t’ may alter its value We do not care if the value is truncated because we are looking for just 32 bits anyway.
This commit is contained in:
parent
eb6f461fc1
commit
3d92c8c827
|
@ -2294,8 +2294,8 @@ unsigned int cmSystemTools::RandomSeed()
|
|||
struct timeval t;
|
||||
gettimeofday(&t, 0);
|
||||
unsigned int pid = static_cast<unsigned int>(getpid());
|
||||
unsigned int tv_sec = t.tv_sec;
|
||||
unsigned int tv_usec = t.tv_usec;
|
||||
unsigned int tv_sec = static_cast<unsigned int>(t.tv_sec);
|
||||
unsigned int tv_usec = static_cast<unsigned int>(t.tv_usec);
|
||||
// Since tv_usec never fills more than 11 bits we shift it to fill
|
||||
// in the slow-changing high-order bits of tv_sec.
|
||||
return tv_sec ^ (tv_usec << 21) ^ pid;
|
||||
|
|
Loading…
Reference in New Issue